Delphi LoadLibrary Failing to find DLL other directory - any good options?

后端 未结 3 1964
忘了有多久
忘了有多久 2021-01-15 09:44

Two Delphi programs need to load foo.dll, which contains some code that injects a client-auth certificate into a SOAP request. foo.dll resides in c:\\fooapp\\foo.dll and is

相关标签:
3条回答
  • 2021-01-15 10:20

    This is not exactly a solution for the question asked, but it would have helped me, when I stumpled upon this question:

    You can extend the search path for LoadLibrary via SetDllDirectory.

    From MSDN-Doku:

    The search path can be altered using the SetDllDirectory function. This solution is recommended instead of using SetCurrentDirectory or hard-coding the full path to the DLL.

    You would have needed to add one line before your LoadLibrary call(s):

    SetDllDirectory(PChar('c:\fooapp'));
    
    0 讨论(0)
  • 2021-01-15 10:22

    Or you can simply edit the environment variable "path" and place the path to the dll in there. In this case adding ;c:\fooapp to the path should be sufficient. Since the environment changes of a parent effects a child, you can also create a loader application which adjusts the its environment variable then spawns to your application.

    0 讨论(0)
  • 2021-01-15 10:30

    The MSDN documentation for LoadLibrary tells you exactly where Windows will search for the DLLs. You either have to hard-code the path to the DLL, put it in the same folder as your app, or put it in one of those default search locations from the LoadLibrary docs.

    0 讨论(0)
提交回复
热议问题