如何获得Windows版本-如“ Windows 10,版本1607”? [英] How to get Windows Version - as in "Windows 10, version 1607"?

查看:121
本文介绍了如何获得Windows版本-如“ Windows 10,版本1607”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows中,版本一词似乎用于不同的事物。例如,Microsoft将Windows 10周年更新标记为版本1607(此处)。但是,如果我尝试使用以下代码获取版本(在安装了周年更新的PC上),则不会返回任何类似于 1607的内容。

It seems that the word "version" in reference to Windows is used for different things. For example, the Windows 10 "Anniversary Update" is labeled "Version 1607" by Microsoft (here for example). But if I try to get the "Version" (on a PC with the Anniversary Update installed) using the following code, nothing is returned that looks like "1607".

// Get Version details
Version ver = os.Version;
Console.WriteLine("Major version: " + ver.Major);
Console.WriteLine("Major Revision: " + ver.MajorRevision);
Console.WriteLine("Minor version: " + ver.Minor);
Console.WriteLine("Minor Revision: " + ver.MinorRevision);
Console.WriteLine("Build: " + ver.Build);

我明白了:

Major version: 6
Major Revision: 0
Minor version: 2
Minor Revision: 0
Build: 9200

如何获得Windows 10版本,如版本1607?

How do I get the Windows 10 "version" as in "Version 1607"?

谢谢!

推荐答案

根据 MSDN官方链接那里每个Windows版本都有一个特定的版本号。在点网中,可以使用Environment.OSVersion对象读取。

according to MSDN official link there's a specific version number for each windows version out there. in dot net this can be read using the Environment.OSVersion object.

Console.WriteLine("OSVersion: {0}", Environment.OSVersion);
//output: OSVersion: Microsoft Windows NT 6.2.9200.0

您在寻找什么被称为ReleaseID而不是Windows版本。
可以从注册表项中读取:

What you are looking for is called ReleaseID not a version of windows. this be can read from registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ReleaseId

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ReleaseId

using Microsoft.Win32;

string releaseId = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ReleaseId", "").ToString();
Console.WriteLine(releaseId);

这篇关于如何获得Windows版本-如“ Windows 10,版本1607”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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