Debugging User Interface Extensions

Once you have written and registered your user interface extension, what do you do if it doesn't work? In most applications, you can simply run Microsoft Visual C++ in debug mode, set some breakpoints, and start debugging. But user interface extensions are loaded at startup for Windows Explorer, so you must find a way to start Windows Explorer without loading all its DLLs. Here's how:

  1. Open your Project menu and choose the Settings item. Click the Debug tab, and type the path to EXPLORER.EXE in the Executable For Debug Session edit box.
  2. Close all applications, and turn off your computer.
  3. Restart Windows 95 and Visual C++, loading your user interface extension.
  4. Click the Start button, and then choose Shutdown.
  5. Hold down the Ctrl-Alt-Shift keys and simultaneously click No. (Sounds a bit like playing Twister, doesn't it?)
  6. The desktop may go blank, and your heart may start palpitating, but don't worry. If you press Alt-Tab, you can get to your instance of Visual C++. At this point, you are ready to debug. Set your breakpoints and go.

If you don't want to exit Windows to debug your extension, you can force the system to unload DLLs very quickly by changing a setting in the Registry. Under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer, add the AlwaysUnloadDll key and set its value to 1. (I always set it to 1, but any value will do.) Adding this key sets the time-out value for DLLs to a very small value.