DLL plugins that depend on other DLLs

I am writing a DLL to connect to another (third-party) application. The DLL will need to depend on another set of DLLs (for license reasons, I cannot link statically).

I would like my DLL to be "xcopy-deployable" in any directory. I would also like not to require adding this directory to the path.

If I just create the DLL in the usual way, Windows will refuse to load the DLL because it cannot find the DLL near the current process.

Are there any good features to help Windows locate a DLL?


To answer some questions:

  • The DLL is written in C ++.
  • Additional DLLs are QT-dll.
  • I would like to place additional DLLs in the same folder as my DLL plugin. I can get the name of this folder from GetModuleFileName .
  • Application - Firefox, DLL is PKCS No. 11 Security Module.
  • The application loads the DLL using the full path to the DLL (the user supplies it when installing the plugin).
  • Requiring DLLs to be hosted on System32 or next to the application will work, but this is a bit messy and can cause problems with uninstallers.
  • LoadLibrary and GetProcAddress , of course, will work, but in my case this is not real. I use hundreds, if not thousands, of methods in other DLLs. I really need to use import libraries.

I thought about using delayed delays in combination with SetDllDirectory in DllMain. Has anyone tried something like this?

+7
c ++ windows dll
source share
3 answers

I can think of three ways.

But if the DLL is not in the same folder as the .exe, how do you know where it is? forget Windows without knowing how you know?

+4
source share

you can specify the path to the dll as parameter LoadLibrary ().

+1
source share

Another option is to change the PATH variable. Have a batch file to launch the main application and set PATH =% PATH%;% ~ dp0. This provides a minimum area, without additional traces remaining in the system after startup.

0
source share

All Articles