如何获得Windows版本

编程入门 行业动态 更新时间:2024-10-26 14:31:03
本文介绍了如何获得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版本

本文发布于:2023-11-05 15:55:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1561261.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何获得   版本   Windows

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!