To detect whether i am using Windows 10 or not, but seems like there is some kind of BUG in windows, that instead of returning the correct windows Version number it returns the wrong version number "6.2.9200" instead of returning "10.0" as that table states.
is there any workaround, to check whether or not i have Windows 10 on my machine using C# ?
That is really unexplained behavior at Microsoft documentations, I wish there is someone from Microsoft in here, to probably suggest a more “official” workaround.
As I believe that’s a common issue in Windows 8.1 and Windows 10. Environment.OSVersion Always returns the wrong version number on those two versions.
But anyways here is my suggested “unofficial” solution to it:
Windows Stores the current OS version friendly name in Registry key:
So you can easily read it using regular registry classes and parse it, Something like this should do the trick:
using Microsoft.Win32;
/// Helper method to check if the currently installed OS version name
/// contains the given string
public bool IsCurrentOSContains(string name)
{
var reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion");
string productName = (string)reg.GetValue("ProductName");
return productName.Contains(name);
}
/// Check if it's Windows 8.1
public void IsWindows8Dot1()
{
return IsCurrentOSContains("Windows 8.1");
}
/// Check if it's Windows 10
public void IsWindows10()
{
return IsCurrentOSContains("Windows 10");
}
Other than this method i don’t know any other method that might work for you.