Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function is called internally by the CoGetClassObject, when the class context indicates a DLL, to load a specific DLL into the caller's process. Applications should not call it directly.

Syntax

HINSTANCE CoLoadLibrary(
  LPOLESTR 
lpszLibName, 
  BOOL 
bAutoFree
); 

Parameters

lpszLibName

[in] Long pointer to the null-terminated string that contains the name of the library to be loaded. The use of this name is the same as in the Win32 function LoadLibrary.

bAutoFree

[in] Ignored. Explicitly unload with the CoFreeLibraryfunction.

Return Value

The handle of the loaded library indicates success. NULL indicates that the library could not be loaded.

Remarks

The CoLoadLibraryfunction is called internally by the CoGetClassObjectfunction when the class context (CLSCTX) indicates a DLL. CoLoadLibraryloads a DLL specified by the lpszLibNameparameter into the process that called CoGetClassObject. Containers should not call CoLoadLibrarydirectly.

Internally, a reference count is kept on the loaded DLL, by using CoLoadLibraryto increment the count and the CoFreeLibraryfunctionto decrement it.

Passing into this function any invalid and, under some circumstances, NULL pointers result in unexpected termination of the application.

To determine whether the platform supports this function, see Determining Supported COM APIs.

Requirements

Header objbase.h
Library ole32.lib
Windows Embedded CE Windows CE 2.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also

Reference

CoFreeLibrary
CoGetClassObject

Other Resources

LoadLibrary