简体   繁体   English

在Windows 7中调试shell扩展

[英]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. 我正在尝试使用Visual C ++ 2008在Windows 7中调试shell扩展(IContextMenu)。我在注册表中设置了DesktopProcess = 1并将主机应用程序设置为explorer.exe。 But when I start the debugger, it launches explorer.exe and then detaches from the process. 但是当我启动调试器时,它会启动explorer.exe然后从进程中分离。 DllMain of the shell extension isn't called. 不调用shell扩展的DllMain。

The same code with exactly the same settings launched in debugger without any problems in Windows XP + Visual C++ 2008. 在Windows XP + Visual C ++ 2008中,在调试器中启动的相同代码具有完全相同的设置,没有任何问题。

Any thoughts how to debug the shell extension in Win7? 有任何想法如何在Win7中调试shell扩展?

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. 我发现了一个很好的工作流程,我认为这是在开发shell扩展时快速迭代代码构建测试周期的最快方法。 The following should work on any Windows version. 以下内容适用于任何Windows版本。

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. 首先准备 - 将shell扩展项目的启动程序设置为c:\\ windows \\ explorer.exe,并将其设置为启动项目。

Then, whenever you want to debug your shell extension perform the following steps: 然后,每当您想要调试shell扩展时,请执行以下步骤:

  • Click on the task bar and press Alt-F4 - this will bring up the shut down dialog 单击任务栏并按Alt-F4 - 这将打开关闭对话框
  • Press Ctrl-Alt-Shift-Escape - this combination will close explorer. 按Ctrl-Alt-Shift-Escape - 此组合将关闭资源管理器。
  • 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. 使用Alt-Tab返回到Visual Studio并按F5 - 资源管理器现在将从一开始就使用VS调试器启动它。
  • 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. 这也将解锁shell扩展DLL,以便您可以再次构建它。

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. Vista和7上的警告 - 确保运行用于在非管理员模式(非提升)下进行调试的Visual Studio,以便以通常的非提升模式启动资源管理器。

尝试启动资源管理器,然后将调试器附加到它。

You could try putting a DebugBreak() call in your code. 您可以尝试在代码中调用DebugBreak()。 This should launch the just-in-time debugger at the call and give you an idea of what is going on. 这应该在调用时启动即时调试器,并让您了解正在发生的事情。

You should take a look at gflags.exe, part of the standard debugging tools sdk. 你应该看看gflags.exe,它是标准调试工具sdk的一部分。 It's got all the options you need to configure (global)flags for any process startup/services/heap/pool-tagging/stacktrace's-on-allocation etc... 它具有为任何进程启动/服务/堆/池标记/堆栈跟踪分配等配置(全局)标志所需的所有选项...

Debugging Explorer.exe is usually overkill for extensions that operate in a shell view. 对于在shell视图中运行的扩展,调试Explorer.exe通常是过度的。

I personally use a little app I made that hosts an instance of IExplorerBrowser similar to this example . 我个人使用了一个我做的小应用程序来托管一个类似于这个例子IExplorerBrowser 实例 If your IContextMenu item is not the default item then you can just use Notepad.exe and its open file dialog... 如果您的IContextMenu项不是默认项,那么您可以使用Notepad.exe及其打开文件对话框...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Windows 8 IShellIconOverlayIdentifier Shell扩展无法正常工作 - windows 8 IShellIconOverlayIdentifier shell extension not working properly 在windows shell命名空间扩展下使用_wopen() - Using _wopen() under windows shell namespace extension Shell扩展:DragQueryFile最多返回16(在Windows 7中) - Shell Extension: DragQueryFile returns at most 16 (in Windows 7) Windows Shell名称空间文件夹视图扩展注册为特定文件扩展名 - Registration of windows shell namespace folder view extension for particular file extension Shell 扩展窗口:ContextMenu 和 IconOverlay 之间的最佳通信? - Shell extension windows : best communication between ContextMenu and IconOverlay? 如何将多个菜单项添加到 Windows Shell 扩展? - Howto add multiple menu items to windows shell extension? 我如何开始编写Windows shell扩展? - How do i begin writing a windows shell extension? Windows Shell扩展程序不提供确切的文件路径 - Windows Shell Extension doesn't give exact file paths Windows Shell扩展教程不会将CLSID添加到注册表 - Windows shell extension tutorial won't add CLSID to registry Windows Store应用程序的扩展SDK在远程调试期间不起作用 - Extension SDK for Windows Store apps doesn't work during remote debugging
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM