如何在不重新启动资源管理器进程的情况下删除桌带并删除其 dll?

发布于 2024-12-17 06:48:55 字数 128 浏览 2 评论 0原文

我在任务栏上创建了一个桌面带。当我想更新桌带的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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

半暖夏伤 2024-12-24 06:48:55

“不支持”(又名 hack)解决方案(C/C++):

HWND hWnd = FindWindowW(L"Shell_TrayWnd", NULL);
if (hWnd != NULL)
    PostMessageW(hWnd, WM_TIMER, 0x18, 0);

这将强制在资源管理器进程中调用 CoFreeUnusedLibraries 函数。

在 Windows 7 Ultimate SP1 64 位和 Windows XP Professional SP3 32 位上进行了测试。

顺便说一句,您可以按 Windows+D(最小化所有窗口)并等待 3 分钟。程序化黑客就是基于这种行为。它只是调用资源管理器进程内的计时器处理程序。处理程序代码(C/C++)为:

KillTimer(hWnd, 0x18);
CoFreeUnusedLibraries();

对于不存在的计时器调用 KillTimer 函数没有什么坏处。

"Unsupported" (aka hack) solution (C/C++):

HWND hWnd = FindWindowW(L"Shell_TrayWnd", NULL);
if (hWnd != NULL)
    PostMessageW(hWnd, WM_TIMER, 0x18, 0);

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:

KillTimer(hWnd, 0x18);
CoFreeUnusedLibraries();

There is no harm in calling of KillTimer function for non-existent timer.

从此见与不见 2024-12-24 06:48:55

不,没有受支持的方法可以执行此操作。 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

逆蝶 2024-12-24 06:48:55

正如马丁所说,没有受支持的方法可以完全满足您的要求。

但您仍然可以减少更新过程的干扰。只需让您的插件 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文