简体   繁体   中英

Finding dependent DLLs when DLL called by LoadLibrary

I have built a DLL which uses a bunch of other DLLs. An external application uses LoadLibrary to load my main DLL. One such example is Excel (the main DLL has the extension .XLL) and another is Python (the main DLL has the extension .PYD).

My plan is to embed a manifest in the main DLL containing the location of the other DLLs so that I don't have to do one or more of the following:

  1. Set the current directory to the directory of the main DLL before the application calls LoadLibrary.
  2. Call SetDllDirectory before the application calls LoadLibrary.
  3. Require all the DLLs to be in the same directory as the main DLL.

Note that I have done all of the above at various points (in fact 1 or 2 in combination with 3) but it doesn't seem entirely satisfactory.

Do I have a chance with my plan? The MSDN documentation on this topic appears opaque to the point of incomprehensibility (ie I have tried to follow it without success).

Somebody marked this as a duplicate and referred to a question which is entirely different. I know the dependencies of my DLL - what I want to be able to do is have a way to inform LoadLibrary where I have placed all the dependent DLLs without having to change directory or use SetDllDirectory. Manifests appear to be designed for this task, but the documentation is so bad that I would like to know whether struggling for many more hours is worth the effort on my part.

I am not away of any way to provide the paths to the other DDLs in a manifest file.

But maybe a way to get around this would be to use the Path environment variable.
Before you call LoadLibrary you add all the paths to the other DLLs to the path environment variable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM