COMCTL32.DLL 加载两次时的 GetModuleHandle 和 GetProcAddress
我正在一个进程中运行,其中 COMCTL32.DLL
被加载两次,一次使用版本 5.82.7601.17514,一次使用版本 6.10.7601.17514。旧版本由程序链接的某个旧 DLL 加载,另一个版本由较新的 DLL 加载。
如果我使用 GetModuleHandle (L"COMCTL32.DLL") ,我无法控制解析的 DLL。
例如,当我调用 GetProcAddress
来访问 TaskDialogIndirect
时,我得到了一个空指针,这肯定是因为我得到了旧 DLL 的句柄。
那么,当两个 DLL 都加载时,是否有某种方法可以获取例如 TaskDialogIndirect
的地址。
如果没有,我能否以某种方式确保该进程加载 6.10 版本而不是 5.82,希望我们的旧版 DLL 能够与新版本的 COMCTL32
正常工作?
I am running inside a process where COMCTL32.DLL
is loaded twice, once with the version 5.82.7601.17514 and once with the version 6.10.7601.17514. The legacy version is loaded by some legacy DLL the program is linked with, and the other version is loaded by a newer DLL.
If I use GetModuleHandle (L"COMCTL32.DLL")
I have no control over the DLL which gets resolved.
When I call GetProcAddress
to reach, for instance, TaskDialogIndirect
, I get a null pointer back, which is certainly because I got back the handle of the legacy DLL.
So, is there some means of getting to the address of, say TaskDialogIndirect
when both DLLs are loaded.
If not, can I somehow make sure that the process loads the 6.10 version and not the 5.82, in the hope that our legacy DLL will work fine with the newer version of COMCTL32
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜您必须使用 GetProcAddress() 而不是隐式链接,因为您希望您的应用程序在任务对话框不可用的 XP 上运行。
我可以为您提供三个选项:
LoadLibrary()
时 comctl32 v6 清单正在运行。调用LoadLibrary()
而不是GetModuleHandle()
以确保您获得了明显的魔力。激活上下文方法是最简洁的解决方案,但激活上下文 API 可能很难使用。我个人用它来确保 Excel COM 加载项链接到 comctl32 v6。
模块枚举方法实现起来很快,虽然有点脏,但效果很好。
I guess you are having to use
GetProcAddress()
rather than implicit linking because you want your app to run on XP where task dialog is not available.I can see three options for you:
LoadLibrary()
. CallLoadLibrary()
rather thanGetModuleHandle()
to make sure that you get the manifest magic.The activation context approach is the cleanest solution, but the activation context API can be tricky to get into. I personally have used it to ensure that an Excel COM add-in links to comctl32 v6.
The module enumeration approach is quick to implement, somewhat dirty, but will work well.