Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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);

I get this:

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

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

Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
455 views
Welcome To Ask or Share your Answers For Others

1 Answer

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

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

HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionReleaseId

using Microsoft.Win32;

string releaseId = Registry.GetValue(@"HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersion", "ReleaseId", "").ToString();
Console.WriteLine(releaseId);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...