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

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
 
M

Mattias Sjögren

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
 
W

Wiktor Zychla

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top