不推荐使用 GetVersion/GetVersionEx 时,如何在 Win8.1 中获取操作系统版本? [英] How to get the OS version in Win8.1 as GetVersion/GetVersionEx are deprecated?

查看:25
本文介绍了不推荐使用 GetVersion/GetVersionEx 时,如何在 Win8.1 中获取操作系统版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些场景,我想特别了解操作系统的主要/次要版本和内部版本号等.

I have scenarios where i want to specifically know the OS major/minor version and build number etc.

从 windows 8.1 开始,GetVersionGetVersionEx 已被弃用,声明:

From windows 8.1 onwards GetVersion and GetVersionEx have been deprecated, stating:

[GetVersion/GetVersionExWindows 8.1 之后的版本可能会更改或不可用.相反,使用版本助手功能]

[GetVersion/GetVersionEx may be altered or unavailable for releases after Windows 8.1. Instead, use the Version Helper functions]

没有 版本帮助程序API 帮助我获取操作系统版本号,而不是帮助我验证或了解我的版本是否与某些提到的版本相同或更高.可以做什么?

None of the version helper APIs help me get the OS version number rather help me verify or get to know if my version is same or above some mentioned version. What can be done?

推荐答案

API GetVersionEx() 继续在 Windows 8.1+ 中工作,但微软改变了它的功能.来自 MSDN(重点是我的):

The API GetVersionEx() continues to work in Windows 8.1+, but Microsoft has altered its functionality. From MSDN (emphasis mine):

随着 Windows 8.1 的发布,GetVersionEx API 的行为已更改为操作系统返回的值版本.GetVersionEx 函数返回的值现在取决于关于应用程序的表现方式.

With the release of Windows 8.1, the behavior of the GetVersionEx API has changed in the value it will return for the operating system version. The value returned by the GetVersionEx function now depends on how the application is manifested.

未针对 Windows 8.1 显示的应用程序将返回 Windows 8操作系统版本值 (6.2).一旦应用程序针对给定的操作系统版本,GetVersionEx 将始终返回版本应用程序将在未来版本中体现出来.体现您的 Windows 8.1 应用程序请参阅定位您的应用程序适用于 Windows 8.1 的应用程序.

Applications not manifested for Windows 8.1 will return the Windows 8 OS version value (6.2). Once an application is manifested for a given operating system version, GetVersionEx will always return the version that the application is manifested for in future releases. To manifest your applications for Windows 8.1 please refer to Targeting your application for Windows 8.1.

您需要做的是将正确的 GUID 添加到您的应用程序 (.exe/.dll) 二进制文件中(通过清单 XML 信息).换句话说,如果您明确声明您的应用程序支持 8.1,GetVersionEx() 将在 Windows 8.1 上运行时返回正确的信息.如果你不这样做,GetVersionEx() 会骗你.

What you need to do is add the proper GUID(s) to your application (.exe/.dll) binaries (via manifest XML information). In other words, if you specifically state your application supports 8.1, GetVersionEx() will return proper information when running on Windows 8.1. If you do not, GetVersionEx() will lie to you.

请参阅将您的应用程序定位到 Windows 8.1 以获取 GUID 列表.也在此处介绍 和这里.

See Targeting your application For Windows 8.1 for a list of GUIDs. Also covered here and here.

懒人的 GUID 列表

  • Vista/Server 2008:{e2011457-1546-43c5-a5fe-008deee3d3f0}
  • Windows 7/Server 2008 R2:{35138b9a-5d96-4fbd-8e2d-a2440225f93a}
  • Windows 8/Server 2012:{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}
  • Windows 8.1/Server 2012 R2:{1f676c76-80e1-4239-95bb-83d0f6d0da78}
  • Windows 10/Server 2016:{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}

至于 Windows Server 2019,我不确定是否发布了新的 GUID.如果你知道更多,请评论!

As for Windows Server 2019, I'm not sure that a new GUID has been released. Please comment if you know more!

这篇关于不推荐使用 GetVersion/GetVersionEx 时,如何在 Win8.1 中获取操作系统版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆