帮助翻译MSDN :
Dynamic-Link Library Search Order
...
If a DLL with the same module name is already loaded in memory, the system checks only for redirection and a manifest before resolving to the loaded DLL, no matter which directory it is in. The system does not search for the DLL.
注意:具有相同名称的多个 DLL 基本上是一个坏主意,这只是为了获得更好的画面。
考虑:
...\x\foo.exe
...\x\a\bar.dll ~ no further dependencies
...\x\b\bar.dll ~ no further dependencies
是否可以通过显式加载库调用将这两个 bar.dll
加载到 foo.exe
中? 和这是在哪里/如何记录和支持的(否则我会尝试一下。)
也就是说,以下是否可以在 Windows7+ 上可靠地工作:
// Load using full path:
HANDLE a_mod = LoadLibrary(L"...\x\a\bar.dll");
HANDLE b_mod = LoadLibrary(L"...\x\b\bar.dll");
// now use moth DLLs ...
最佳答案
来自文档(强调我的):
Desktop applications can control the location from which a DLL is loaded by specifying a full path, using DLL redirection, or by using a manifest. If none of these methods are used, the system searches for the DLL at load time as described in this section.
Before the system searches for a DLL, it checks the following:
- If a DLL with the same module name is already loaded in memory, the system uses the loaded DLL, no matter which directory it is in. The system does not search for the DLL.
因此,当提供完整路径时,您担心的子句不适用。
关于windows - 一个进程可以加载两个名称完全相同的 DLL 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43217552/