Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Let's look at the documentation for <a href="http://msdn.microsoft.com/en-us/library/ms684175%28v=vs.85%29.aspx" rel="nofollow">LoadLibrary on MSDN</a>:</p> <blockquote> <p>If the string specifies a full path, the function searches only that path for the module. If the string specifies a relative path or a module name without a path, the function uses a standard search strategy to find the module; for more information, see the Remarks.</p> </blockquote> <p>Ok, so that explains the behavior of #1 above. If you had said:</p> <pre><code>LoadLibrary("C:\\program files\\AppFolder\\Sub\\com_server.dll") </code></pre> <p>Then that would have found your dependent DLLs, and LoadLibrary would have succeeded.</p> <p>As for how COM succeeds with #2, that really depends on how com_server.dll is registered in the registry for the InProcServer32 key. If it's a full path to the file, then LoadLibrary would just work as described above. If it's a relative path, then I would suspect COM could be doing any number of things to make finding DLLs like yours work.</p> <p>One likely possibility is that CoCreateInstance is calling <a href="http://msdn.microsoft.com/en-us/library/ms684179%28v=vs.85%29.aspx" rel="nofollow">LoadLibraryEx</a> with the <strong>LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR</strong> flag set. It may even call LoadLibrary(Ex) multiple times with different combination of flags.</p> <p>Also, given that CoCreateInstance is a system API, it's entirely possible it has a private internal version of LoadLibrary that allows for alternate search paths.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload