getting the OS and distinguishing between XP Home and XP Pro?

  • Thread starter Thread starter Bennett Haselton
  • Start date Start date
B

Bennett Haselton

I have a program that uses the System.Environment.OSVersion to report
on the platform where it's running:

Console.WriteLine(System.Environment.OSVersion.ToString());
Console.WriteLine(System.Environment.OSVersion.Platform.ToString());
Console.WriteLine(System.Environment.OSVersion.Version.ToString());

However this code gives the same output on both XP Home and XP Pro:

Microsoft Windows NT 5.1.2600.0
Win32NT
5.1.2600.0

What C# call could I use to find out if I'm running on XP Home or XP
Pro?

-Bennett
 
Bennett,
What C# call could I use to find out if I'm running on XP Home or XP
Pro?

I think you have to call the GetVersionEx API via P/Invoke and check
if OSVERSIONINFOEX.wSuiteMask contains VER_SUITE_PERSONAL.



Mattias
 
Console.WriteLine(System.Environment.OSVersion.ToString());
Console.WriteLine(System.Environment.OSVersion.Platform.ToString());
Console.WriteLine(System.Environment.OSVersion.Version.ToString());

However this code gives the same output on both XP Home and XP Pro:

Microsoft Windows NT 5.1.2600.0
Win32NT
5.1.2600.0

I have no idea how to do it with pure .NET libraries.

However, with GetVersionEx() from Win32API you just check the field
wSuiteMask of OSVERSIONINFOEX structure to distinguish XPHome from XPPro.
Probably you'll have to PInvoke GetVersionEx().

look at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/bas
e/osversioninfoex_str.asp for more details.

Regards, Wiktor
 
Back
Top