您的位置:首页 > 其它

GetVersionEx的降级问题

2016-03-18 14:49 375 查看

GetVersionEx在win8.1以后的系统中被MS降级,如果程序的目标平台没有指明,则该函数缺省返回6.2.0000(win8.0的版本号),为了准确使用该函数获取系统版本号,需要指明程序兼容的目标平台,方法如下:

1、创建CVPlatform.manifest,其中的trustInfo 节用于指明以管理员权限执行程序。

<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.5.0.0" processorArchitecture="X86" name="Microsoft.Windows.CVPlatform" type="win32"/>
<description>CVPlatform</description>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="requireAdministrator"
uiAccess="false"
/>
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
</application>
</compatibility>
</assembly>

2、在VS2015的工程属性->manifest Tool->input and output的additional manifest files下加入CVPlatform.manifest的路径。

3、重新编译。

注意:VS2015提供了添加trustInfo的其他配置位置,需要保持与CVPlatform.manifest的一致。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: