How can I make a separate folder for my applicatio

2019-07-19 09:19发布

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?

3条回答
贪生不怕死
2楼-- · 2019-07-19 09:46

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

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

  • Have the installer modify the PATH variable. This is intrusive and "bad form"
  • Write a "loader" application that locally modifies the path variable, then executes the real executable.

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

查看更多
▲ chillily
3楼-- · 2019-07-19 09:49

DLL redirection is a fairly new feature (Windows 2000 IIRC). Name your DLL directory <myapp>.exe.local, and Windows will check it first for anything loaded via LoadLibrary(Ex). This includes delay-loaded DLLs.

查看更多
\"骚年 ilove
4楼-- · 2019-07-19 09:53

EDIT: As pointed out by Eric this doesn't work. Sorry.

See Dynamic-Link Library Search Order. In short you can do so using registry keys under the "HKEY_LOCAL_MACHINE\SORTWARE\Microsoft\Windows\CurrentVersion\App Paths" key. A reg file like the following shows how:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\MyApp.exe]
@="C:\\Program Files\\MyCompany\\MyApp\\MyApp.exe"
"Path"="C:\\Program Files\\MyCompany\\MyApp\\MyDLLs"
查看更多
登录 后发表回答