简体   繁体   English

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

[英]how can i remove a deskband and delete its dll without restart the explorer process?

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. 当我想更新桌面带的DLL时,我将其隐藏起来,取消注册,但是不幸的是,资源管理器仍将该DLL保留在内存中。

How can I update the dll without restart the explorer process? 如何在不重新启动资源管理器进程的情况下更新dll? There is any Windows api for such a case? 有这种情况的Windows API吗?

"Unsupported" (aka hack) solution (C/C++): “不受支持的”(又名hack)解决方案(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. 这将在资源管理器过程中强制调用CoFreeUnusedLibraries函数。

Tested on Windows 7 Ultimate SP1 64-bit and Windows XP Professional SP3 32-bit. 在Windows 7 Ultimate SP1 64位和Windows XP Professional SP3 32位上进行了测试。

BTW, you can hit Windows+D (to minimize all windows) and wait for 3 minutes. 顺便说一句,您可以按Windows + D(以最小化所有窗口)并等待3分钟。 The programmatic hack is based on this behaviour. 编程黑客就是基于这种行为。 It just calls the timer handler inside explorer process. 它只是在资源管理器进程中调用计时器处理程序。 And the handler code (C/C++) is: 处理程序代码(C / C ++)为:

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

There is no harm in calling of KillTimer function for non-existent timer. 对于不存在的计时器,调用KillTimer函数没有害处。

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. DLL最早可能会卸载,如果它从DllCanUnloadNow返回true且之间有一定延迟(例如,由CoFreeUnusedLibraries触发),则该DLL必须来自资源管理器进程。 Unregistering it will have no impact. 取消注册不会有任何影响。

If you are developing this kind of DLL, you need to get comfortable with restarting explorer. 如果您正在开发这种DLL,则需要重新启动资源管理器。

Martyn 马丁

As Martyn says there is no supported way to do exactly what you are asking. 正如Martyn所说,没有一种支持的方法可以完全按照您的要求进行。

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. 只需让您的插件DLL充当资源管理器的准系统界面,然后将其他所有内容卸载到单独的DLL,您就可以从进程中显式加载和卸载该DLL。 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. 如果操作正确,则几乎不必更新插件DLL。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM