如何为我的应用程序的DLL创建一个单独的文件夹?

如何为我的应用程序的DLL创建一个单独的文件夹?

问题描述:

我已经成功地将一个大型MFC项目分成了两个更小的DLL项目。现在我想在我的应用程序的文件夹中有一个名为DLL的单独文件夹,其中放置所有来自子项目的所有DLL。

I have successfully divided a large MFC project into a couple of smaller DLL projects. Now I want to have a separate folder called "DLL" in my application's folder, where all the all the DLLs from the subprojects are placed.

任何人都可以指导我如何实现这一目标。

Can anybody give me guidance in how to achieve this?

如果你使用LoadLibrary,你只需要明确指定加载的DLL的完整路径。

If you use LoadLibrary, you simply have to explicitly specify the full path of the DLLs you load.

如果DLL是隐式链接的,你可以通过两种方式

If the DLLs are implicitly linked, you can do this in two ways.


  • 让安装程序修改PATH变量。

  • 编写一个加载器应用程序,在本地修改路径变量,然后执行真正的可执行文件。

最好的解决方案是将DLL放在与可执行文件相同的目录中。

The best solution would be to simply put the DLLs in the same directory as the executable.