WinXP下如何修复DWMAPI.DLL延迟加载依赖?

发布于 2024-07-06 22:16:29 字数 1944 浏览 4 评论 0原文

我在 WinXP 下构建了一个 .dll,声称加载时找不到 DWMAPI.DLL。 问题在于该 DLL 是 Vista DLL,对于安装了 IE7 的 XP 用户来说这是一个已知问题。 建议卸载 IE7 或通过添加/删除程序修复 .NET Framework。 我修复了,没有任何变化。 我不打算卸载 IE7,因为一定有更好的解决方案,而不是相当于“重新安装 Windows”。

我读过一些关于试图卸载 IE7 的人的坏消息,所以我不愿意走这条路。

我在 Visual Studio 2003 (7.1) 下使用 C++。 我没有看到在应用程序启动时强制延迟加载的选项。 我在创建 DLL 项目时只使用了默认设置。 我刚刚发现了一个有趣的选项,Linker->Input->Delay Loaded DLLs,所以我将 DWMAPI.DLL 放在那里以强制它延迟加载。 然而,我在链接时得到了这个:

LINK : warning LNK4199: /DELAYLOAD:dwmapi.dll ignored; no imports found from dwmapi.dll

..并且在尝试加载我的 DLL 时它当然没有改变任何事情。 更糟糕的是,我添加了导致 DWMAPI.DLL 的整个 DLL 树,并且得到了相同的消息。 (根据记录,它是foundation.dll->shell32.dll->shdocvw.dll->mshtml.dll->ieframe.dll->dwmapi.dll。)

更具体地说我是什么为此,我正在编写一个 Maya 插件,并在脚本编辑器中获取始终有用的文本:

// Error: Unable to dynamically load : D:/blahblahblah/mydll.mll
The specified module could not be found.
 //
// Error: The operation completed successfully.
 //
// Error: The operation completed successfully.
 (mydll) //

我使用 Dependency Walker 来最初追踪问题,这就是我找到 DWMAPI.DLL 的原因。 这些是取决于给我的消息,DWMAPI.DLL 是唯一旁边有黄色问号的东西:

Warning: At least one delay-load dependency module was not found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.

Gerald 是对的。 事实上,Maya 使用与 Dependency Walker 不同的路径。 我的插件加载了位于 Maya 插件目录中的另一个 DLL(用于图像处理),并且依赖项发现它没有问题,但 Maya 没有。 我必须将“;plug-ins”添加到 Maya.env 中的 PATH 中。

鉴于此问题毕竟与 DWMAPI.DLL 无关,但 DWMAPI 是一个常见问题,因此我将在 Novell 网站上发布我找到的有关 DWMAPI 问题的最佳链接 此处。 基本上,大多数程序都会在depends.exe中出现此警告,但如果它旁边有一个延迟加载图标,并且您确定该程序不会直接或间接调用DWMAPI,那么就可以了。 问题出在别处。 如果延迟加载图标不存在,则必须查看 Visual Studio 中的 /DELAY 和 /DELAYLOAD 选项。 事实上,depend 给了我一个“警告”而不是一个“错误”,这是 DWMAPI 没有自动加载这一事实的线索。

I have built a .dll under WinXP that claims it can't find DWMAPI.DLL when it's loaded. The problem is that this DLL is a Vista DLL, and this a known issue for XP users that have IE7 installed. The recommendation is to uninstall IE7 or repair the .NET Framework via Add/Remove programs. I did the repair, and nothing changed. I'm not about to uninstall IE7 since there must be a better solution that's not the equivalent of "reinstall windows".

I've read bad things about people who attempted to uninstall IE7, so I'm reluctant to go that route.

I am using C++ under Visual Studio 2003 (7.1). I don't see an option where I may have forced delay loading at application launch. I just used default settings when I created the DLL project. I did just now find an interesting option, Linker->Input->Delay Loaded DLLs, so I put DWMAPI.DLL in there to force it to be delay-loaded. However, I get this when linking:

LINK : warning LNK4199: /DELAYLOAD:dwmapi.dll ignored; no imports found from dwmapi.dll

.. and it of course didn't change a thing when trying to load my DLL. For the heck of it, I added the whole tree of DLLs that lead to DWMAPI.DLL, and I get the same message. (For the record, it's foundation.dll->shell32.dll->shdocvw.dll->mshtml.dll->ieframe.dll->dwmapi.dll .)

To be more specific about what I'm doing, I am writing a Maya plugin and get the always-helpful text in the script editor:

// Error: Unable to dynamically load : D:/blahblahblah/mydll.mll
The specified module could not be found.
 //
// Error: The operation completed successfully.
 //
// Error: The operation completed successfully.
 (mydll) //

I used Dependency Walker to initially track down the problem, and that's what lead me to DWMAPI.DLL. These are the message depends gives me, and DWMAPI.DLL is the only thing that has a yellow question mark next to it:

Warning: At least one delay-load dependency module was not found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.

Gerald is right. Maya is, in fact, using a different PATH than the Dependency Walker. My plug-in loads another DLL (for image processing) that lives in the Maya plug-ins directory and depends found it with no problem, but Maya didn't. I had to add ";plug-ins" to the PATH in Maya.env.

Seeing as this problem wasn't related to DWMAPI.DLL after all, but DWMAPI is a common problem, I'll post the best link I found about the DWMAPI issue on Novell's website here. Basically, most programs will have this warning in depends.exe, but if there is a delay-load icon next to it, and you are sure that the program won't directly or indirectly call DWMAPI, then it's fine. The problem is elsewhere. If the delay-load icon isn't present, then you have to look at the /DELAY and /DELAYLOAD options in Visual Studio. The fact that depends gave me a "warning" and not an "error" was a clue to the fact that DWMAPI is not being loaded automatically.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

末が日狂欢 2024-07-13 22:16:29

根据您更新的问题,DWMAPI.dll 可能不是您的问题。 每当您链接到 mshtml 时,Dependency Walker 总是会给出该错误,因为它总是检查延迟加载的 DLL。

此时,我最好的猜测是,您已将项目设置为动态加载运行时库,并且 Maya 正在更改 DLL 的搜索路径。 因此它可能无法找到 MSVC 运行时 DLL。 我已经很长时间没有开发 Maya 插件了,但最近我在使用其他具有插件 DLL 的应用程序时遇到了这个问题。

尝试将 C/C++->代码生成->运行时库中的设置更改为多线程而不是多线程 DLL。

除此之外,您可以尝试摆弄 Dependency Walker,使其使用与 Maya 相同的搜索路径,看看是否可以提出另一个依赖问题。

作为最后的手段,您可以在调试器中启动 Maya 并在 LoadLibrary 上设置断点,然后找出哪个库没有以这种方式加载。

Based on your updated problem, DWMAPI.dll is probably not your problem. Dependency walker will always give you that error whenever you are linking to mshtml as it always checks delay loaded DLLs.

At this point my best guess is that you have your project set to dynamically load the runtime libraries and the search path for DLLs is being changed by Maya. So it may be unable to find the MSVC runtime DLL(s). I haven't developed Maya plugins in a long time, but I've had that problem with other apps that have plugin DLLs recently.

Try changing your setting in C/C++->Code Generation->Runtime Library to Multi-Threaded rather than Multi-Threaded DLL.

Aside from that you can try fiddling with Dependency Walker to make it use the same search paths as Maya and see if you can come up with another dependency problem.

As a last resort you can launch Maya in a debugger and set a breakpoint on LoadLibrary and find out which library is not being loaded that way.

对你的占有欲 2024-07-13 22:16:29

这是一个棘手的问题。 实际上有两种主要方式会导致此错误。

1) 您将项目设置为强制延迟加载的 DLL 在应用程序启动时加载。 DWMAPI.dll 是一个延迟加载的 DLL,因此通常不会加载,除非调用它的函数之一。 除非您尝试在 DLL 中执行此操作,否则在 XP 上不会发生这种情况。 但可以设置编译器选项来强制应用程序加载延迟加载的 DLL。 如果你这样做,就不要这样做。

2) 当出现其他问题时,depends.exe 通常会出现错误。 通过依赖项遍历器运行您的 DLL,并查看是否存在任何其他依赖项问题。 如果以上方法均无效,请尝试卸载 IE7,看看问题是否仍然存在。 如果是假错误,安装IE7后您将看到真正的错误。 之后您可以再次安装IE7。

This is a tricky one. There's really 2 main ways you will get this error.

1) You have your project set to force delay loaded DLLs to load at application launch. DWMAPI.dll is a delay-loaded DLL and thus normally will not be loaded unless one of it's functions is called. That won't happen on XP unless you're trying to do it in your DLL. But it's possible to set a compiler option to force your app to load the delay loaded DLLs anyway. If you're doing that, don't.

2) It's often a false error that you will get from depends.exe when there is another problem. Run your DLL through dependency walker and see if there are any other dependency problems. If all else fails, try uninstalling IE7 and see if the problem persists. If it is a false error, after you install IE7 you will see the real error. You can install IE7 again afterwards.

独﹏钓一江月 2024-07-13 22:16:29

我正是遇到这个问题。

需要几个小时才能解决的偷偷摸摸的问题。

反正。 我在发布机器上编译了我的托管 C++ 应用程序。 收到客户的投诉,无法运行它,但它在我们所有的机器上都发挥了作用。

原来,发布机在一个月前的一个晚上就被自动打上了ATL漏洞修复补丁,其他所有机器也是如此,除了一台XP机器。

该特定 XP 计算机也无法运行该应用程序。 安装了 ATL 修复程序(请参阅下面的链接),瞧,一切都像以前一样工作。

http://www.microsoft.com/downloads/details.aspx microsoft.com/downloads/details.aspx?familyid=766A6AF7-EC73-40FF-B072-9112BAB119C2&displaylang=en

所以吸取教训,总是检查你的中间清单(在调试或发布目录中找到),这将告诉您该程序所链接的 DLL 版本。

希望它对任何人都有帮助。

I had exactly this problem.

Sneaky problem that took hours to solve.

Anyway. I compiled my managed C++ application on the release machine. Got complaints from customers that could not run it, worked like a charm on all of our machines.

It turned out that the release machine was automatically patched one night a month ago with the ATL vulnerability fix, and so was all other machines also, except one XP machine.

That particulare XP machine could not run the application either. Installed the ATL fix (see link below), and voilá, every thing worked just like before.

http://www.microsoft.com/downloads/details.aspx?familyid=766A6AF7-EC73-40FF-B072-9112BAB119C2&displaylang=en

So lesson learned, always check your intermediate manifests (found the in debug or release directory), that will tell you what version of the DLL that the program have been linked against.

Hope it helps anyone.

静谧幽蓝 2024-07-13 22:16:29

尝试将 C/C++->代码生成->运行时库中的设置更改为多线程而不是多线程 DLL。

Try changing your setting in C/C++->Code Generation->Runtime Library to Multi-Threaded rather than Multi-Threaded DLL.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文