如何获取 Windows 11 的操作系统版本信息
GetVersionEx Api 可以用 C++ 获得 Windows10 版本。
#include <windows.h>
#include <stdio.h>
void main()
{
OSVERSIONINFO osvi;
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osvi);
}
版本帮助程序函数有一个 IsWindows10OrGreater api,可以检查它是 Windows10 或更高版本,但我需要 Windows11 的版本信息。有没有像 GetVersionEx 这样的 Api 我可以从那里获取 Windows11 的完整版本信息。
The GetVersionEx Api can get version upto Windows10 in C++.
#include <windows.h>
#include <stdio.h>
void main()
{
OSVERSIONINFO osvi;
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&osvi);
}
Version Helper functions have an IsWindows10OrGreater api that can check it's Windows10 or greater but i need exactly the version info of Windows11. Is there any Api like GetVersionEx from there i can get the whole version info of Windows11.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么不使用 dwBuildNumber 来识别 Windows 11 版本? Windows 11 内部版本号从 22000 开始,您可以在线搜索所需的确切内部版本号。
Why don't you use the
dwBuildNumber
for identifying the Windows 11 Version? Windows 11 build number starts from 22000, and you can search up online the exact build number you are looking for.直接(但不推荐):
GetVersion
和GetVersionEx
均已弃用。也就是说,如果您确实想检测 Windows 11,则可以使用GetVersionEx
返回的OSVERSIONINFOEX
的dwBuildNumber
成员。 “https://learn.microsoft.com/en-us/windows/release-health/windows11-release-information” rel="nofollow noreferrer">Windows 11 发布信息页面,dwBuildNumber
的值 22000 及以上将指示 Windows 11。推荐方式: 引用此页面:https://learn.microsoft.com/en-us/windows/win32/sysinfo/operating-system-version
Direct (but not recommended way): Both
GetVersion
andGetVersionEx
are deprecated. That said, you can use thedwBuildNumber
member ofOSVERSIONINFOEX
returned byGetVersionEx
if you really want to detect Windows 11. From the Windows 11 release information page, a value 22000 and above fordwBuildNumber
would indicate Windows 11.Recommended Way: Quoting from this page: https://learn.microsoft.com/en-us/windows/win32/sysinfo/operating-system-version