11

Win8.1 and Win8 has the same OS Version. How can we check if the current OS is Win8 or Blue? The Environment.OSVersion is giving us the same results:

Environment.OSVersion 6.2.9200.0 Environment.OSVersion.Version 6.2.9200.0 Environment.OSVersion.Version.Major 6 Environment.OSVersion.Version.Minor 2

4444
  • 3,541
  • 10
  • 32
  • 43
Khaleel Hmoz
  • 987
  • 2
  • 13
  • 24

4 Answers4

19

Windows 8.1 will lie to you and tell you it is Window 8. Changing that lie requires editing the manifest that is embedded in your program so that Windows knows you don't want to be lied to. Project + Add New Item, select the Application Manifest File item template. Copy paste this verbiage underneath the <application> element:

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> 
    <application> 
        <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
    </application> 
</compatibility>
Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
2

I found a solution under this Registry Key

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion
nawfal
  • 70,104
  • 56
  • 326
  • 368
Khaleel Hmoz
  • 987
  • 2
  • 13
  • 24
0

Since I wasn't able to get Hans' solution working, I created a different solution:

bool _IsWindows8Point1OrGreater = Type.GetType("Windows.UI.Xaml.Controls.Flyout, Windows.UI.Xaml, ContentType=WindowsRuntime", false) != null;
HDW Production
  • 1,402
  • 10
  • 13
  • Just tested on win8 and 8.1 as well, both return false. – fishmong3r May 30 '14 at 13:47
  • 1
    Thanks for downvoting after 7 months. I just tested on Windows 8.1 and Windows Phone 8.1, both return true. Now what? The "Runtime" part might be worth noting: The solution is for RT. – HDW Production May 30 '14 at 14:30
0

In case of Win8.1 the version is 6.3.*

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

If you are using GetVersionEx() api [from kernel32.dll] for getting Win8.1 version, the value returned will be 6.2.* whereas the version value should be 6.3.*

The solution to this is either you need to add assembly manifest to the .net exe or os.dll to state that symhelp will run on windows 8.1, that might make the .net System.Environment.OSVersion.Version function correctly.

However you need to test it on multiple OS's.

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

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

AMIT SHELKE
  • 501
  • 3
  • 12
  • 34