Debugging Win32 Shell Extensions

It's been a while since I wrote a Win32 Shell Extension. FYI, shell extensions are used to extend Windows Explorer and Internet Explorer. By extension, I mean custom context menu items, property pages, detail columns, shell namespaces, etc.

Like everything, shell extension is a double-edged technology. While it enables deeper integration with Windows, buggy implementations can ruin user experience severely. For example, TortoiseSVN, which integrates Subversion nodes as shell namespaces, occasionally causes Explorer to crash.

Anyhow, I learned a new debugging trick this time (adding a custom detail view column and a custom property sheet for executable files) which made debugging much easier.

  1. Open 'Turn Off Computer' Dialog (Start>>Turn Off Computer).
  2. Press Cancel button with ALT-CONTROL-SHIFT keys down.

This shuts down current Explorer.exe cleanly. With your shell extension project set to use explorer.exe as debug target application, just launch and debug. When you are done, repeating the above steps will end your debug session. Just killing your debug session also seems to cause little problem. I know that there are other debugging tricks like configuring Explorer to launch new instances for each window but I found them to be confusing in practice.

Note that the instance of Explorer launched by Visual Studio will be owned by Visual Studio so it will shutdown also if you shutdown Visual Studio, causing Windows to relaunch Explorer. You should keep a pair of script files to register and unregister your shell extensions.

Advertisements