简体   繁体   中英

Why OS.Version reports Windows 8.0 for Windows 8.1?

When use Environment.OSVersion.Version.ToString(); on this mode

MessageBox.Show(Environment.OSVersion.Version.ToString()); show the value 6.2 when use ver command on CMD return 6.3

I have Windows 8.1 Professional Edition Original

like this (the messageBox is a RadMessageBox from Telerik Controls): 在此处输入图片说明

Why?

This is a feature , not a bug. It is because Windows 8.1 will only report the version as 6.3 to applications which have been specifically targeted to that platform.

See here and here for official documentation.

From the manual ;

The OSVersion property reports the same version number (6.2.0.0) for both Windows 8 and Windows 8.1.

In other words, a documented "limitation".

http://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx

If you look here you find that it depends on the manifest of your application. Look at the star point :)

I have used this method!

RegistryKey key2 = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, "");
                RegistryKey subkey2 = key2.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion");
                string value = subkey2.GetValue("CurrentVersion").ToString();
                if (value == "6.3")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM