简体   繁体   中英

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.

How can I update the dll without restart the explorer process? There is any Windows api for such a case?

"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.

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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