如何在桌面应用程序中检测 Windows 8.1

问题描述:

在 Windows 8.1 预览版中,Environment.OSVersion.Version 返回与 Windows 8 相同的版本号.是否有检测 Windows 8.1 的替代方法.

In the Windows 8.1 preview Environment.OSVersion.Version returns the same version numbers as Windows 8. Is there alternative way of detecting Windows 8.1.

看看这篇文章:

Windows 8.1 Preview 中的操作系统版本变化

GetVersion(Ex) API 已被弃用.这意味着虽然您仍然可以调用 API,但如果您的应用不是专门针对 Windows 8.1 Preview,您将获得 Windows 8 版本控制 (6.2.0.0).

GetVersion(Ex) APIs have been deprecated. That means that while you can still call the APIs, if your app does not specifically target Windows 8.1 Preview, you will get Windows 8 versioning (6.2.0.0).

它所说的是 GetVersion 对您来说有关真实操作系统版本的信息,除非您在清单中明确指示 8.1.

What it says is that GetVersion lies to you about the real OS version unless you explicitly direct 8.1 in your manifest.

您需要将以下内容添加到应用清单中:

You need to add the following to the app manifest:

 <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> 
    <application> 
      * <!-- 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>

如果您不想这样做,可以检查以下注册表项:

If you don't want to do that you can check the following registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion

当前版本将为您提供 6.3

Current version will give you 6.3

当前版本号为 9431

Current build nmber will be 9431