First, you are not “statically loading” anything. D in DLL - dynamic; all DLL files are linked dynamically, no matter what. Static communication is how DCU and OBJ files are included in your program. You cannot link statically with a DLL.
You are talking about dynamic load-time linking, when the OS loads the DLL for you implicitly due to the functions listed in the program import table, as opposed to the dynamic link-time linking, where you call LoadLibrary using whatever you want. When you use the external directive to define your function, you create an entry in the import table, and as far as I know, relative paths are pointless there. The OS searches for DLLs at boot time (and runtime) using a specific documented search order . In general, this is the application’s own directory, the current directory, the system directory, the Windows directory, and then everything else in the PATH environment variable.
In your case, the current directory and the system directory are the same place, and in any case, you have no control over them. Do not put your DLLs in the Windows directory; which already has enough material that does not belong there.
It is best to place your DLL files in the same directory as your EXE service. If you do not want this, then you can put enough to load your program into one DLL in this directory, and then load everything else later using LoadLibrary , using any separate DLL directory that you want.
You can put your DLLs somewhere else, and then add this directory to your PATH environment variable. However, this variable is a shared resource, so think twice before changing it.
source share