I am currently working on a code to collect information on Windows version.
I have made a Manifest file so it works on win 7 and up.
The thing is in my code i have a case for each NT version (6.0, 6.1...6.2) but the thing is it only reads 6 and not other then that and show up as Windows Vista on vista and above.
Heres a part of the code:
static public string Edition
{
get
{
if (s_Edition != null)
return s_Edition; //***** RETURN *****//
string edition = String.Empty;
OperatingSystem osVersion = Environment.OSVersion;
OSVERSIONINFOEX osVersionInfo = new OSVERSIONINFOEX();
osVersionInfo.dwOSVersionInfoSize = Marshal.SizeOf(typeof(OSVERSIONINFOEX));
if (GetVersionEx(ref osVersionInfo))
{
int majorVersion = osVersion.Version.Major;
int minorVersion = osVersion.Version.Minor;
byte productType = osVersionInfo.wProductType;
short suiteMask = osVersionInfo.wSuiteMask;
#region VERSION 4
if (majorVersion == 4)
else if (majorVersion == 6.1)
{
int ed;
if (GetProductInfo(majorVersion, minorVersion,
osVersionInfo.wServicePackMajor, osVersionInfo.wServicePackMinor,
out ed))
{
switch (ed)
{
case PRODUCT_PROFESSIONAL:
edition = "Professional";
break;
how can i get it to read 6.1?
Also this part won't show other than Vista:
static public string OSName
{
get
{
if (s_Name != null)
return s_Name; //***** RETURN *****//
string name = "unknown";
OperatingSystem osVersion = Environment.OSVersion;
OSVERSIONINFOEX osVersionInfo = new OSVERSIONINFOEX();
osVersionInfo.dwOSVersionInfoSize = Marshal.SizeOf(typeof(OSVERSIONINFOEX));
if (GetVersionEx(ref osVersionInfo))
{
int majorVersion = osVersion.Version.Major;
int minorVersion = osVersion.Version.Minor;
switch (osVersion.Platform)
{
case PlatformID.Win32Windows:
{
if (majorVersion == 4)
{
string csdVersion = osVersionInfo.szCSDVersion;
switch (minorVersion)
{
case 0:
if (csdVersion == "B" || csdVersion == "C")
name = "Windows 95 OSR2";
else
name = "Windows 95";
break;
case 10:
if (csdVersion == "A")
name = "Windows 98 Second Edition";
else
name = "Windows 98";
break;
case 90:
name = "Windows Me";
break;
}
}
break;
}
case PlatformID.Win32NT:
{
byte productType = osVersionInfo.wProductType;
switch (majorVersion)
{
case 3:
name = "Windows NT 3.51";
break;
case 4:
switch (productType)
{
case 1:
name = "Windows NT 4.0";
break;
case 3:
name = "Windows NT 4.0 Server";
break;
}
break;
case 5:
switch (minorVersion)
{
case 0:
name = "Windows 2000";
break;
case 1:
name = "Windows XP";
break;
case 2:
name = "Windows Server 2003";
break;
}
break;
case 6:
switch (productType)
{
case 1:
name = "Windows Vista";
break;
case 2:
name = "Windows Server 2008";
break;
}
break;
case 7:
switch (productType)
{
case 1:
name = "Windows 7";
break;
case 2:
name = "Windows Server 2008 R2";
break;
}
break;
case 8:
switch (productType)
{
case 1:
name = "Windows 8";
break;
case 2:
name = "Windows Server 2012";
break;
}
break;
case 9:
switch (productType)
{
case 1:
name = "Windows 8.1";
break;
case 2:
name = "Windows Server 2012 R2";
break;
}
break;
case 10:
switch (productType)
{
case 1:
name = "Windows 10";
break;
case 2:
name = "Windows Server 2016";
break;
}
break;
}
break;
}