在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版本
发布评论