none
How to unload a shell extension dll from Explorer?

    Question

  • Hi all,

    I'm developing a shell extension that adds a context menu item to explorer. In DllRegisterServer and DllUnregisterServer I have the neccesary code to add or remove it from the registery respectively and also added a call to SHChangeNotify(SHCNE_ASSOCCHANGED, ...) at the end of these functions in order for Explorer to show or remove the shell extension immidiately. It all works fine, except of one thing: the dll remains loaded in the Explorer.exe process.

    The problem with that is that in order to upgrade that dll to a newer version, Explorer must be restarted (otherwise the file is locked and you get an Access Denied error), which is a very ugly user experience! Note that when Explorer is restarted it closes all of its open windows...

    How can I make my dll unload from Explorer without having to restart it?

    Thanks,
    Arnon.
    Wednesday, March 11, 2009 3:17 PM

All replies

  • I'm guessing but maybe that can be done manually from IE - Tools menu - Internet Options - Programs tab - Manage Add-ons. I appreciate you probably don't want to do it manually...
    Wednesday, March 11, 2009 6:46 PM
  • Shell Extension is an extension to (Windows) Explorer (Explorer.exe), not Internet Explorer (IExplorer.exe)...
    Thursday, March 12, 2009 7:17 AM
  • I want an answer to this question too. I want to remove TxView.dll without restarting.
    Saturday, December 19, 2009 10:37 AM
  • Unloading the DLL
    The Shell automatically unloads a DLL when its usage count is zero, but only after the DLL has not been used for a period of time. This inactive period might be unacceptably long at times, especially when a Shell extension DLL is being debugged. For operating systems prior to Windows 2000, you can shorten the inactive period by adding the following information to the registry.


    HKEY_LOCAL_MACHINE
    Software
    Microsoft
    Windows
    CurrentVersion
    Explorer
    AlwaysUnloadDll

    In the right hand pane look for the "(Default)" String [REG_SZ] value. Make sure its value is 1.
    If not present, create a new Registry subkey: highlight the "explorer" subkey (see above) -> right-click in the left hand pane -> select New -> Key -> type AlwaysUnloadDll -> hit Enter -> highlight the new "AlwaysUnloadDll" subkey -> double-click on the "(Default)" String Value in the right hand pane -> type 1 -> click OK or hit Enter


    And as all some DLLs are stay-resident DLLs: they get loaded and stay loaded. Others get loaded when they're called and unloaded after. It's up to the DLL developer whether or not their DLL should be stay-resident.


    Thanks Mike --------Please mark as answer if it is useful----------
    Monday, January 11, 2010 4:24 AM
  • Well guys, I have a question regarding this, does the AlwaysUnloadDll registry key still work for Windows XP, Vista and 7? because this article http://support.microsoft.com/kb/196480 says that: Important This registry key is no longer supported in Microsoft Windows 2000 or later. So, is this registry key really having an effect, or is it just staying there doing nothing?
    Tuesday, June 08, 2010 7:00 AM
  • HI arnon,

     

    i am facing the same problem now, did you find any solution for the problem you mentioned.

     

    thanking you in advance.

    Monday, January 10, 2011 11:56 AM
  • I didn't find a solution for unloading the DLL, but we found a workaround for the upgrade problem:

    If the file is in use, we copy the new file with a different name and load it (after we unregistered the old one). This makes the 2 dlls loadedm, but only the new one is in used until the next restart. In addition, we add a RunOnce command to delete the old dll and rename the new one to its original name.

    HTH,

    Arnon.


    Arnon Axelrod
    Tuesday, January 11, 2011 6:45 AM