CoLoadLibrary

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.

At a Glance

Header file: Objbase.h
Windows CE versions: 2.0 and later

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] Boolean that is set to TRUE if this library is freed when it is no longer needed, through a call to either the CoFreeUnusedLibraries or CoUninitialize functions, or to FALSE if the library should be explicitly freed with the CoFreeLibrary function.

Return Values

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

Remarks

The CoLoadLibrary function is called internally by the CoGetClassObject function when the class context (CLSCTX) indicates a DLL. CoLoadLibrary loads a DLL specified by the lpszLibName parameter into the process that called CoGetClassObject. Containers should not call CoLoadLibrary directly.

Internally, a reference count is kept on the loaded DLL, by using CoLoadLibrary to increment the count and the CoFreeLibrary function to decrement it.

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