Desktop Functions:

   Smart Device Functions:

Show Recent Changes
Subscribe (RSS)
Misc. Pages
Helpful Tools
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
cofreeunusedlibraries (ole32)

Unloads any DLLs that are no longer in use and whose unload delay has expired.

     unloadDelay - The delay in milliseconds between the time that the DLL
     has stated it can be unloaded until it becomes a candidate to unload.
     Setting unloadDelay=INFINITE uses the system default delay (10 minutes).
     Setting unloadDelay=0 forces the unloading of any DLLs without any delay.
     reserved - Reserved for future use; must be zero.

C# Signature:

public static extern void CoFreeUnusedLibrariesEx(UInt32 unloadDelay, UInt32 reserved);

VB Signature:

Declare Function CoFreeUnusedLibrariesEx Lib "ole32.dll" (TODO) As TODO

User-Defined Types:


Alternative Managed API:

Do you know one? Please contribute it!


Setting the delay too short (or zero) can have unintended consequences, as some DLL's will return control before they have finished cleaning up resources, or they will continue executing in the background.

Tips & Tricks:

Please add some!

Sample Code:

public static void FreeDllsNow(UInt32 pause)


        CoFreeUnusedLibrariesEx(pause, (UInt32)0);
    catch (Exception ex)
        string exStr = ex.ToString();



Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

Access directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version