简体   繁体   English

在Visual Studio '13中,我该怎么做,以便可以在exe的相对子文件夹中包含dll文件?

[英]In visual studio '13 how do I make it so I can include dll files in a relative sub folder of my exe?

在C#中,我知道有一种方法可以编辑汇编配置文件或类似的文件,但是对于C ++,我不知道如何创建它,而不是将我的所有dll放在根目录中,例如/ libs或/ bin /文件夹,我的exe将在其中查找dll文件?

Your EXE doesn't look for DLL files. 您的EXE不会寻找DLL文件。 That means it doesn't matter whether you're using C++ or C#. 这意味着无论您使用的是C ++还是C#。 Visual Studio is even less relevant as it's not even present when your EXE runs. Visual Studio的相关性甚至更低,因为在EXE运行时甚至不存在。

Windows looks for DLLs. Windows查找DLL。 In your C# example, Windows uses the assembly manifest to guide the search. 在您的C#示例中,Windows使用程序集清单来指导搜索。 In your C++ example, you didn't add one, so Windows uses just the default paths. 在您的C ++示例中,您没有添加一个,因此Windows仅使用默认路径。 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"); 如果在运行时加载DLL,则只需编写hDll = LoadLibrary("subFolder\\\\test.dll"); . At first Windows looks for the DLL in the directory your program is located. 首先,Windows在程序所在的目录中查找DLL。 Therefore test.dll will be found in app_dir/subFolder/test.dll (app_dir = path of executable). 因此test.dll将中找到app_dir/subFolder/test.dll (APP_DIR =可执行的路径)。 Note that this also works if the current directory is different to app_dir . 请注意,如果当前目录不同于app_dir ,则这也适用。

Look at MSDN for more information about DLL searching . 有关DLL搜索的更多信息 ,请参见MSDN。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何让Visual Studio将所需的.dll文件复制到release文件夹中? - How can I make Visual Studio copy the required .dll files into the release folder? 我在笔记本电脑上找不到文件夹C:\\ Program Files(x86)\\ Microsoft Visual Studio 14.0 \\ VC \\ include \\ gl。 如何添加? - I cannot find the folder C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\gl on my laptop. How do I add it? 如何使我的应用程序使用Visual Studio查找第三方DLL? - How can I make my application find a third-party DLL using Visual Studio? 如何告诉 Visual Studio 我的其他 .dll 文件在哪里? - How can I tell Visual studio where my additional .dll files are? 是否可以将SDL .lib,.dll和头文件放在某个地方,所以我只需要键入#include <SDL2.h> 在Visual Studio 2017 RC项目中? - Is it possible to put the SDL .lib, .dll, and header files somewhere so I can just type #include <SDL2.h> in a visual studio 2017 RC project? 如何授予对源文件夹的包含访问权限,以便在使用库时可以通过包含文件间接访问源? - How do I give my include access to my source folder so when the library is used it can be indirectly accessed to the source via the include file? 如何在Visual Studio 2010 C ++中使用所需的.dll和lib(opencv)文件制作.exe文件包 - How to make package of .exe file with required .dll and lib (opencv) files in visual studio 2010 C++ 如何在Xcode中将文件夹设置为全局包含,类似于Visual Studio? - How do I set a folder as a global include in Xcode, similar to Visual Studio? 如何使用 Visual Studio Express 2005 制作完全静态链接的 .exe? - How do I make a fully statically linked .exe with Visual Studio Express 2005? 如何使用 bat 文件在 Visual Studio 中设置 DLL 文件的路径? - How do I set the path to DLL files in Visual Studio using bat file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM