Download the DLL from another directory at program startup

My main problem is this: my program (MyProgram.exe) is dependent on the DLL for another program (OtherProgram), and I try to avoid repackaging the new DLL every time I update OtherProgram. I would like to have the MyProgram.exe link in the OtherProgram DLL when it starts, but I'm not entirely sure that Windows allows this. Therefore, if there is some workaround that will also be acceptable.

And only for some background, the platform is Windows 7 x64, and MyProgram.exe works fine when I create a symbolic link in the MyProgram.exe project directory in the DLL in the OtherProgram installation directory. When I try to start it without a symbolic link, I get a message stating that "the program does not start because the error" OtherProgramDLL.dll is missing from your computer ".

Any tips or links to relevant information are welcome!

EDIT: Clarification: The DLL is not linked at compile time, this problem occurs at runtime

+5
source share
6 answers

In the Windows world, there are two types of dynamic linking:

  • Load-Time - DLL . Windows DLL, , .
  • - DLL, LoadLibrary . , , .

MS , DLL , . , , , .

, , . - , DLL , .

:

  • .
  • " " , DLL.

DLL.

:

  • , , ,
  • PATH.
+10

, dll PATH.

+2

LoadLibrary, DLL. Wikipedia , DLL .

+2

, , LoadLibrary, SetDllDirectory, Qt addLibraryPath . , , , ( ) , .

, , , : ! ( )

Windows :

@echo off
PATH=%PATH%;<PATH_TO_YOUR_LIB>
<PATH_TO_YOUR_APP_EXE>

/edit: @SirDarius Luchian answer, , .

+1

, Aaron Margosis . :

NTFS 64- Windows

, . . , "" , .

0

, .

, , .

- , , , , , - Windows 7. Vista.

, , Windows Application development, , Delay-Loaded DLL, . DLL , , . , , SetDllDirectory.

:

1) , DLL ​​, makefile, cmake VS (Linker- > Input VS2015)

2) Call SetDllDirectory at the beginning of your program before any DLL call is made.

DLL load delay is fully supported back in VC6. SetDllDirectory is supported after XP SP1.

0
source

All Articles