需要有关运行时错误的帮助 [英] Need Help With Runtime Error

查看:83
本文介绍了需要有关运行时错误的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在MFC应用程序中使用仅在win vista和更高版本中有效的代码,因为它需要一个不在winXP中的dll文件.

这是我的代码:

I want to use a code in my MFC application that it works only in win vista and higher, because it needs a dll file that it''s not in winXP.

This is my code:

if ( ... ) //  check win 7 or Vista
DwmIsCompositionEnabled();


在win 7中可以正常工作,但是我的问题是,当我在 XP 中,在运行时中运行应用程序时,并且在检查操作系统的代码之前,它因该错误而中断:

"此应用程序无法启动,因为未找到dwmapi.dll.重新安装该应用程序可能会解决问题."

有什么主意吗?


It works fine in win 7, but my problem is when I run the application in XP, in run time and before the code that checked the OS, it breaks with this error:

"This application has failed to start because dwmapi.dll was not found. Re-Installing the application may fix the problem."

Is there any idea?

推荐答案

尝试使用 ^ ]函数来验证操作系统版本.我认为您还需要修改可执行文件,以使 dwmapi 不会链接到程序,而是在确定您使用的是正确的操作系统后就动态加载.
Try using the GetVersionEx()[^] function to verify the OS version. I think you will also need to modify your executable so that dwmapi is not linked in to the program but loaded dynamically once you have determined that you are on the correct OS.


您可以使用WMI查询从系统中获取操作系统详细信息.以下文章将帮助您做到这一点.

在C ++中进行WMI查询 [
You can use WMI Query to fetch OS detials from system. the following article will help to do same.

Making WMI Queries In C++[^]


这是因为我在附加内容"中添加了"dwmapi.lib"依赖关系.当我在Win XP中运行该应用程序时,它想找到"dwmapi.lib"作为第一步,因此会中断.
现在,我使用了另一种方式:
It was because of "dwmapi.lib" that I put in Additional Dependencies. When I run the application in Win XP, it wants to find "dwmapi.lib" as the first step, so it breaks.
Now I used another way:
if ( ... ) //  check win 7 or Vista
   hLib = LoadLibrary( L"dwmapi.dll" );
   GetProcAddress( hLib, "DwmIsCompositionEnabled" );
.
.
.


这篇关于需要有关运行时错误的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆