如何在不重新启动资源管理器进程的情况下删除桌带并删除其 dll?
我在任务栏上创建了一个桌面带。当我想更新桌带的DLL时,我隐藏它,取消注册它,但不幸的是资源管理器仍然将这个DLL保留在内存中。
如何在不重新启动资源管理器进程的情况下更新 dll?有没有针对这种情况的Windows api?
I created a deskband on taskbar. When I want to update the DLL of the deskband, I hide it , unregister it,but unfortunately the explorer still keeps this DLL in the memory.
How can I update the dll without restart the explorer process? There is any Windows api for such a case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
“不支持”(又名 hack)解决方案(C/C++):
这将强制在资源管理器进程中调用 CoFreeUnusedLibraries 函数。
在 Windows 7 Ultimate SP1 64 位和 Windows XP Professional SP3 32 位上进行了测试。
顺便说一句,您可以按 Windows+D(最小化所有窗口)并等待 3 分钟。程序化黑客就是基于这种行为。它只是调用资源管理器进程内的计时器处理程序。处理程序代码(C/C++)为:
对于不存在的计时器调用 KillTimer 函数没有什么坏处。
"Unsupported" (aka hack) solution (C/C++):
This will force the call of CoFreeUnusedLibraries function in the explorer process.
Tested on Windows 7 Ultimate SP1 64-bit and Windows XP Professional SP3 32-bit.
BTW, you can hit Windows+D (to minimize all windows) and wait for 3 minutes. The programmatic hack is based on this behaviour. It just calls the timer handler inside explorer process. And the handler code (C/C++) is:
There is no harm in calling of KillTimer function for non-existent timer.
不,没有受支持的方法可以执行此操作。 DLL 最早可能会卸载,如果它从 DllCanUnloadNow 多次返回 true,中间有延迟——例如由必须来自资源管理器进程内的 CoFreeUnusedLibraries 触发。取消注册不会有任何影响。
如果您正在开发此类 DLL,则需要熟悉重新启动资源管理器。
马丁
No, there's no supported way to do this. The earliest the DLL might unload would be if it returned true from DllCanUnloadNow a couple of times with a delay in between -- triggered for example by a CoFreeUnusedLibraries which would have to come from within the explorer process. Unregistering it will have no impact.
If you are developing this kind of DLL, you need to get comfortable with restarting explorer.
Martyn
正如马丁所说,没有受支持的方法可以完全满足您的要求。
但您仍然可以减少更新过程的干扰。只需让您的插件 DLL 充当资源管理器的准系统接口,并将其他所有内容卸载到一个单独的 DLL 中,您可以从进程中显式加载和卸载该 DLL。然后,当界面发生变化时,您只需要重新加载资源管理器。如果做得正确,您应该很少需要更新插件 DLL。
As Martyn says there is no supported way to do exactly what you are asking.
But you can still make the update process less intrusive. Just have your plugin DLL serve as only a barebones interface to explorer, and offload everything else to a separate DLL which you can explicitly load and unload from the process. Then you only need to reload explorer when something has to change with the interface. If done right you should rarely have to update the plugin DLL.