Question

The description of CoLoadLibrary() says it does pretty much the same as LoadLibraryEx() - loads a DLL into the process. COM classes creation functions - CoCreateInstance() and CoGetClassObject() - both do load the necessary DLL into the process too.

Then why is CoLoadLibrary() needed in the first place and how should it be used?

Was it helpful?

Solution

Have a look at the code:

mov     edi,edi
push    ebp
mov     ebp,esp
push    8
push    0
push    dword ptr [ebp+8]
call    dword ptr [ole32!_imp__LoadLibraryExW (71eb1214)]
pop     ebp
ret     8

So it just calls:

LoadLibraryEx( FileName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH ).

Presumably, the routine merely exists for backwards compatibility -- it probably has its roots in Win16.

OTHER TIPS

Perhaps if you were writing your own regsvr32.exe? But JP's disassembly doesn't really support my guess, because you could just use LoadLibraryEx instead. Maybe in the olden days, Microsoft planned on COM DLLs someday being loaded in a different way than regular DLLs (D-COM?), so this was a way of ensuring future compatibility.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top