1 out of 1 rated this helpful - Rate this topic

CoLoadLibrary function

Applies to: desktop apps only

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

lpszLibName [in]

The name of the library to be loaded.

bAutoFree [in]

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

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Objbase.h

Library

Ole32.lib

DLL

Ole32.dll

See also

CoFreeAllLibraries
CoFreeLibrary
CoFreeUnusedLibraries
CoFreeUnusedLibrariesEx

 

 

Send comments about this topic to Microsoft

Build date: 3/7/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Does CoGetClassObject call CoLoadLibrary or not?
The remarks say that CoGetClassObject doesn't call CoLoadLibrary, yet they also say CoLoadLibrary loads a DLL into the process that called CoGetClassObject? How does it do that? How does CoLoadLibrary takes the opportunity to load into the process that called CoGetClassObject if it's not called by CoGetClassObject? Shouldn't the remarks say "CoLoadLibrary loads ... into the process that called __CoLoadLibrary__"???