当前位置: 首页 > news >正文

海口网站建设搜q.479185700培训网

海口网站建设搜q.479185700,培训网,建德广元建设有限公司网站,寮步做网站场景 开发WTL/ATL/Win32程序时, 有时候需要获取系统版本号,以便判断用户在使用软件时的系统。在某一天突然发现获取的系统版本号是错的, 一直是版本号6.2.x,什么情况? 说明 如果软件没有针对Win8.1或Win10以上的系统做兼容处理,返回的是Wi…

场景

  1. 开发WTL/ATL/Win32程序时, 有时候需要获取系统版本号,以便判断用户在使用软件时的系统。在某一天突然发现获取的系统版本号是错的, 一直是版本号6.2.x,什么情况?

说明

  1. 如果软件没有针对Win8.1Win10以上的系统做兼容处理,返回的是Windows8OS版本值6.2。这就是为什么只调用Win32 API GetVersionEx会一直返回6.2的版本号原因[4]。要正确获取系统版本号,还要另外在程序清单文件里增加以下的配置,参考[1].
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"><application><!-- Windows 10 and Windows 11 --><supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/><!-- Windows 8.1 --><supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/><!-- Windows 8 --><supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/><!-- Windows 7 --><supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/><!-- Windows Vista --><supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> </application>
</compatibility>
  1. Visual Studio 2017为例,在项目属性-》清单工具-》输入和输出-》附加清单文件 里增加文件gdi-aware.manifest.

    • 注意以下部分时用于DPI处理的,可以去掉, 参考[5]:
    <asmv3:application><asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings"><dpiAware>true</dpiAware></asmv3:windowsSettings>
    </asmv3:application>
    
    • 注意以下部分是针对32位程序的兼容性问题的, 如果只支持64位程序可以不用添加。
    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"><security><requestedPrivileges><!--UAC settings:- app should run at same integrity level as calling process- app does not need to manipulate windows belonging tohigher-integrity-level processes--><requestedExecutionLevellevel="asInvoker"uiAccess="false"/>   </requestedPrivileges></security>
    </trustInfo>
    

例子

  1. 注意,这个文件一般用于嵌入清单,这样EXE程序不会因为没有清单文件而导致获取错误。

  2. 在没嵌入清单文件gdi-aware.manifest前,在Win11上获取系统版本号是6.2.9200 Service Pack 0.0, 嵌入之后的到正确的版本号10.0.22631 Service Pack 0.0

test.cpp

void TestGetOSVersion()
{OSVERSIONINFOEX osver = { 0 };osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);  // 6.2.9200 Service Pack 0.0// gdi-aware.manifest// 10.0.22631 Service Pack 0.0if (GetVersionEx((LPOSVERSIONINFO)&osver)){cout << osver.dwMajorVersion << "." << osver.dwMinorVersion << "." << osver.dwBuildNumber<< " Service Pack " << osver.wServicePackMajor << "."<< osver.wServicePackMinor << endl;}else {cout << "Error" << endl;}
}

gdi-aware.manifest

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"><asmv3:application><asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings"><dpiAware>true</dpiAware></asmv3:windowsSettings></asmv3:application><compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"><application><!-- Windows 10 and Windows 11 --><supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/><!-- Windows 8.1 --><supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/><!-- Windows 8 --><supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/><!-- Windows 7 --><supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/><!-- Windows Vista --><supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> </application></compatibility><trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"><security><requestedPrivileges><!--UAC settings:- app should run at same integrity level as calling process- app does not need to manipulate windows belonging tohigher-integrity-level processes--><requestedExecutionLevellevel="asInvoker"uiAccess="false"/>   </requestedPrivileges></security></trustInfo></assembly>

参考

  1. 让你的应用程序面向 Windows - Win32 apps

  2. GetVersionEx 函数 - Win32 apps

  3. 版本帮助程序函数 - Win32 apps

  4. 操作系统版本 - Win32 apps

  5. 关于graphics.DrawImage绘图时显示不正常的问题

http://www.hkea.cn/news/103599/

相关文章:

  • 网上商城网站建设意义在线代理浏览网页
  • 网站图片切换代码百度下载并安装最新版
  • 微信公众平台号申请注册入口杭州seo公司
  • 本周实时热点新闻事件seo文章代写一篇多少钱
  • 旺店通app手机企业版下载网站seo如何优化
  • 宝山区建设用地事务所网站网络公司有哪些
  • 用sql做简单的博客网站大连谷歌seo
  • 新手怎么学做网站就业培训机构有哪些
  • magento网站建设搭建网站步骤
  • 营销网站如何实现差异化南京seo公司
  • 服务器托管是啥搜索引擎优化排名培训
  • 山西手机网站建设网址大全123
  • b2c平台有哪些平台网址新区seo整站优化公司
  • WordPress突然全站404网站如何添加友情链接
  • 复制别人网站做第一站seo短视频网页入口引流下载
  • 基层建设论文收录在哪个网站百度统计api
  • 购买主机可以做网站吗楚雄今日头条新闻
  • 深圳专业网站建设公司哪家好宁波网络营销公司
  • ps做电商网站流程图百度图片识别搜索引擎
  • 做电影网站程序好用武汉网站建设推广公司
  • 如何做b2c网站下列关于友情链接说法正确的是
  • 网站开发中网页上传seo在线网站推广
  • 网站建设报价流程免费培训网站
  • 聊城网站建设服务好最新网域查询入口
  • 一般网站建设流程有哪些步骤官方百度app下载安装
  • 档案网站建设的步骤八大营销方式有哪几种
  • 手机网站免费制作平台semseo
  • 周口市做网站小红书seo排名
  • 网站开始怎么做的ps培训
  • 去哪个网站找题目给孩子做保定百度首页优化