在C#中,我知道有一种方法可以编辑汇编配置文件或类似的文件,但是对于C ++,我不知道如何创建它,而不是将我的所有dll放在根目录中,例如/ libs或/ bin /文件夹,我的exe将在其中查找dll文件?
Your EXE doesn't look for DLL files. That means it doesn't matter whether you're using C++ or C#. Visual Studio is even less relevant as it's not even present when your EXE runs.
Windows looks for DLLs. In your C# example, Windows uses the assembly manifest to guide the search. In your C++ example, you didn't add one, so Windows uses just the default paths. The solution is thus obvious: use a similar manifest.
If you're loading the DLL at runtime you can simply write hDll = LoadLibrary("subFolder\\\\test.dll");
. At first Windows looks for the DLL in the directory your program is located. Therefore test.dll
will be found in app_dir/subFolder/test.dll
(app_dir = path of executable). Note that this also works if the current directory is different to app_dir
.
Look at MSDN for more information about DLL searching .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.