简体   繁体   English

不同Windows版本的相同版本号

[英]Same version number for different Windows versions

In this page , there is something like this: 在此页面中 ,是这样的:

Windows Server 2008 6.0 Windows Server 2008年6.0

Windows Vista 6.0 Windows Vista 6.0

GetVersionEx() returns the version number (ie 6.0), but as you can see, this number can map to two different Windows versions! GetVersionEx()返回版本号(即6.0),但是如您所见,该数字可以映射到两个不同的Windows版本!

So is there's a way to know exactly what Windows version I have? 那么有没有一种方法可以确切地知道我拥有哪个Windows版本?

The GetVersionInfoEx API returns a fully populated OSVERSIONINFOEX structure (if requested). GetVersionInfoEx API返回一个完全填充的OSVERSIONINFOEX结构 (如果需要)。 The documentation contains a complete table, alongside instructions on how to distinguish between OS versions with identical version numbers: 文档包含一个完整的表格,以及有关如何区分具有相同版本号的OS版本的说明:

The following table summarizes the values returned by supported versions of Windows. 下表总结了受支持的Windows版本返回的值。 Use the information in the column labeled "Other" to distinguish between operating systems with identical version numbers. 使用标记为“其他”的列中的信息来区分版本号相同的操作系统。

For your particular example you would need to compare OSVERSIONINFOEX.wProductType against VER_NT_WORKSTATION . 对于您的特定示例,您需要将OSVERSIONINFOEX.wProductTypeVER_NT_WORKSTATION进行比较。 If it is equal, you're on Windows Vista, otherwise you are on Windows Server 2008. 如果相等,则您使用的是Windows Vista,否则,您使用的是Windows Server 2008。

To get reliable results for Windows 8.1 and above, your application needs to be manifested to be compatible. 为了在Windows 8.1及更高版本上获得可靠的结果,您的应用程序必须证明是兼容的。 Instructions on manifesting an application for Windows 8.1 and above are available at Targeting your application for Windows . 针对Windows 8.1及更高版本显示应用程序的说明可在“ 针对Windows应用程序定位”中找到。

Sample manifest file: 清单文件示例:

<?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>

Some version numbers correspond to both a client and server release of Windows. 一些版本号与Windows的客户端和服务器版本均对应。

You can use the IsWindowsServer function to distinguish between client and server versions of Windows, combine that with the version number and you have the exact version. 您可以使用IsWindowsServer函数区分Windows的客户端版本和服务器版本,并将其与版本号结合使用,即可获得确切的版本。

However if you're trying to detect whether some feature is supported, checking the version numbers isn't the recommended way, you may want to use LoadLibrary and GetProcAddress instead to check for features. 但是,如果您尝试检测是否支持某些功能,则不建议使用检查版本号的方法,您可能想使用LoadLibraryGetProcAddress来检查功能。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 有效地为不同的Windows版本使用不同的API - Using different API for different Windows versions efficiently 如何按名称获取Windows版本(用于将来的Windows版本)? - How to get Windows version by name (for future Windows versions)? 应用程序中是否存在两个相同库(具有相同名称)的不同版本? - Can two different versions of the same libs (with same name) exists in an application? 如何将项目链接到同一C静态库的两个不同版本? - How to link a project to two different versions of the same C static library? C:如何同时链接到不同的库版本 - C: How to link with different library versions at the same time 为什么同一个程序的 c 和 fortran 版本会产生不同的结果? - Why the c and fortran versions of this same program produce different results? 5位数字的反转&检查原始号码和反转号码是不同的还是相同的? - Reverse of 5 digit number & check orignal number and reverse number is different or same? 使用GetFileVersionInfo和VerQueryValue获取Windows 10的完整版本号时出现问题 - Problem getting full version number for Windows 10 with GetFileVersionInfo and VerQueryValue 确定性随机数发生器为同一种子提供不同的随机数 - determinisitic random number generator giving different random number for same seed 在C中使用不同的数值获得相同操作的不同长度 - Getting different lengths for the same operation with different number values in C
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM