When and why to use CoLoadLibrary?

The description of CoLoadLibrary () says that it is almost the same as LoadLibraryEx () - it loads a DLL into this process. The COM class creation functions - CoCreateInstance () and CoGetClassObject () - both load the required DLL into this process.

Then why is CoLoadLibrary () necessary in the first place and how to use it?

+1


a source to share


2 answers


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 procedure just exists for backward compatibility - it probably has its roots in Win16.

+4


a source


Perhaps if you wrote your own regsvr32.exe? But JP disassembly doesn't support my guess, because you can just use LoadLibraryEx instead. Maybe in the old days Microsoft planned to load COM libraries in a different way than regular DLLs (D-COM?) Someday, so this was a way to ensure future compatibility.



+1


a source







All Articles