Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


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

CoFreeUnusedLibrariesEx (ole32)
 
.
Summary

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:

[DllImport("ole32.dll")]
public static extern void CoFreeUnusedLibrariesEx(UInt32 unloadDelay, UInt32 reserved);

VB Signature:

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

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

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)

{

    try
    {
          CoFreeUnusedLibrariesEx(pause, (UInt32)0);
        System.Threading.Thread.Sleep((int)pause);
        CoUninitialize();
    }
    catch (Exception ex)
    {
        string exStr = ex.ToString();
        //Console.WriteLine(exStr);
    }

}

Documentation

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 PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions