加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

windows – 进程可以加载两个名称完全相同的DLL吗?

发布时间:2020-12-14 04:26:15 所属栏目:Windows 来源:网络整理
导读:帮助解释 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
帮助解释 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基本上是个坏主意,这只是为了获得更好的图片.

考虑:

...xfoo.exe
...xabar.dll ~ no further dependencies
...xbbar.dll ~ no further dependencies

是否可以使用显式加载库调用将这两个bar.dll加载到foo.exe中?以及/如何记录和支持(否则我只是尝试它.)

也就是说,以下是否可以在Windows7上可靠地工作:

// Load using full path:
HANDLE a_mod = LoadLibrary(L"...xabar.dll");
HANDLE b_mod = LoadLibrary(L"...xbbar.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.

因此,当您提供完整路径时,您担心的条款不适用.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读