I'm loading a DLL in an application. If I have the full path hardcoded in the program, it looks like this:
LPCWSTR dllPath = L"C:\\MyLibs\\PernumLib.dll";
HINSTANCE hinstDLL = LoadLibraryW(dllPath);
I've modified the code to:
LPCWSTR dllPath = L"PernumLib.dll";
HINSTANCE hinstDLL = LoadLibraryW(dllPath);
It works as long as the DLL is either in C:\Windows\System32
or in the same folder as the exe
file. But I want to link the DLL from C:\MyLibs
. I tried the parameter Properties->Linker->General->Additional Library Directory, but it apparently doesn't define the search path for LoadLibraryW()
. There are quite a few configurable directories under Properties->Configuration Properties->VC++ Directories, but they don't apply either. I've tried basically every directory I've found in Visual Studio Properties without success.
I know I can use the function SetDllDirectoryW()
in the code, and it works. But it is another form of hardcoding.
Is there any way to configure the search path for LoadLibraryW()
in Visual Studio?