[英]Same version number for different Windows versions
在此页面中 ,是这样的:
Windows Server 2008年6.0
Windows Vista 6.0
GetVersionEx()
返回版本号(即6.0),但是如您所见,该数字可以映射到两个不同的Windows版本!
那么有没有一种方法可以确切地知道我拥有哪个Windows版本?
GetVersionInfoEx API返回一个完全填充的OSVERSIONINFOEX结构 (如果需要)。 该文档包含一个完整的表格,以及有关如何区分具有相同版本号的OS版本的说明:
下表总结了受支持的Windows版本返回的值。 使用标记为“其他”的列中的信息来区分版本号相同的操作系统。
对于您的特定示例,您需要将OSVERSIONINFOEX.wProductType
与VER_NT_WORKSTATION
进行比较。 如果相等,则您使用的是Windows Vista,否则,您使用的是Windows Server 2008。
为了在Windows 8.1及更高版本上获得可靠的结果,您的应用程序必须证明是兼容的。 针对Windows 8.1及更高版本显示应用程序的说明可在“ 针对Windows应用程序定位”中找到。
清单文件示例:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<assemblyIdentity
type="win32"
name=SXS_ASSEMBLY_NAME
version=SXS_ASSEMBLY_VERSION
processorArchitecture=SXS_PROCESSOR_ARCHITECTURE
/>
<description> my foo exe </description>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="asInvoker"
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>
一些版本号与Windows的客户端和服务器版本均对应。
您可以使用IsWindowsServer函数区分Windows的客户端版本和服务器版本,并将其与版本号结合使用,即可获得确切的版本。
但是,如果您尝试检测是否支持某些功能,则不建议使用检查版本号的方法,您可能想使用LoadLibrary
和GetProcAddress
来检查功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.