Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging shell extension in Windows 7

I'm trying to debug shell extension (IContextMenu) in Windows 7 with Visual C++ 2008. I have set DesktopProcess=1 in the registry and set host app to explorer.exe. But when I start the debugger, it launches explorer.exe and then detaches from the process. DllMain of the shell extension isn't called.

The same code with exactly the same settings launched in debugger without any problems in Windows XP + Visual C++ 2008.

Any thoughts how to debug the shell extension in Win7?

like image 491
CodeSnake Avatar asked Aug 26 '09 01:08

CodeSnake


People also ask

What is shell extension in Windows?

Shell extensions can be represented as individual plug-ins to Windows Explorer. They can be used to add a new tab to the Properties window, change a file preview, and do other things. Before taking any action, the Shell calls registered extension handlers to customize this action.


2 Answers

I've found a nice workflow that I think is the fastest way to rapidly iterate the code-build-test cycle when developing shell extensions. The following should work on any Windows version.

First prepare - set the start program of your shell extension project to be c:\windows\explorer.exe and also set it to be the start-up project.

Then, whenever you want to debug your shell extension perform the following steps:

  • Click on the task bar and press Alt-F4 - this will bring up the shut down dialog
  • Press Ctrl-Alt-Shift-Escape - this combination will close explorer.
  • Use Alt-Tab to go back to Visual Studio and press F5 - explorer will now launch with the VS debugger attached to it from the very beginning.
  • When done, just stop the debugger session. This will kill the debugged instance of explorer and will also automatically start a normal instance of it. This will also unlock the shell extension DLL so that you can build it again.

Caveat on Vista and 7 - be sure to run the Visual Studio that you use for debugging in non-Administrator mode (non-elevated), so that the explorer is started in its usual non-elevated mode.

like image 152
Stefan Dragnev Avatar answered Sep 20 '22 11:09

Stefan Dragnev


Try launching explorer and THEN attaching the debugger to it.

like image 44
snowdude Avatar answered Sep 20 '22 11:09

snowdude