CoLoadLibrary function (objbase.h)

Loads a specific DLL into the caller's process.

CoLoadLibrary is equivalent to LoadLibraryEx. CoLoadLibrary does not affect the lifetime of the library.

Syntax

HINSTANCE CoLoadLibrary(
  [in] LPOLESTR lpszLibName,
  [in] BOOL     bAutoFree
);

Parameters

[in] lpszLibName

The name of the library to be loaded.

[in] bAutoFree

This parameter is maintained for compatibility with 16-bit applications, but is ignored.

Return value

If the function succeeds, the return value is a handle to the loaded library; otherwise, it is NULL.

Remarks

The CoGetClassObject function does not call CoLoadLibrary. 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.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header objbase.h
Library Ole32.lib
DLL Ole32.dll
API set ext-ms-win-com-ole32-l1-1-5 (introduced in Windows 10, version 10.0.15063)

See also

CoFreeAllLibraries

CoFreeLibrary

CoFreeUnusedLibraries

CoFreeUnusedLibrariesEx