c - 不同 Windows 版本的版本号相同

标签 c winapi

在此page ,有这样的东西:

Windows Server 2008 6.0

Windows Vista 6.0

GetVersionEx()返回版本号(即 6.0),但正如您所看到的,该数字可以映射到两个不同的 Windows 版本!

有没有办法准确知道我的 Windows 版本?

最佳答案

GetVersionInfoEx API 返回完全填充的 OSVERSIONINFOEX structure (如果需要的话)。 documentation包含一个完整的表格,以及有关如何区分具有相同版本号的操作系统版本的说明:

The following table summarizes the values returned by supported versions of Windows. Use the information in the column labeled "Other" to distinguish between operating systems with identical version numbers.

对于您的特定示例,您需要将 OSVERSIONINFOEX.wProductTypeVER_NT_WORKSTATION 进行比较。如果相等,则您使用的是 Windows Vista,否则您使用的是 Windows Server 2008。

要获得 Windows 8.1 及更高版本的可靠结果,您的应用程序需要证明是兼容的。有关显示适用于 Windows 8.1 及更高版本的应用程序的说明,请访问 Targeting your application for Windows .

示例 list 文件:

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

关于c - 不同 Windows 版本的版本号相同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30828181/

相关文章:

c++ - Win32 异步套接字基本问题

c - 在 C 中的单独函数中初始化指针

在 C 中创建 *** 对象(指向指针的指针)

ruby - Win3 2's FindWindow() can find a particular window with the exact title, but what about "try.bat - 记事本”?

C++,Win32 LoadString 包装器

java - 如何使用 Win32 API 直接从驱动器读取/写入驱动器

为 windows mobile 6 编译 zlib

c - 如何使用 FCGI 检测客户端终止的连接?

objective-c - 在 Apple 上合并静态库

c++ - 创建在新 Windows 桌面上运行 IE 的进程