Getting windows version and type

G

Guest

I can get the windows version number from System.Environment.OSVersion e.g.
"Windows NT 5.1.2600.0" for XP SP2.
I was wondering whether this tells you the type of windows it is or if you
have to use something else?
E.g. for windows 2000 do you just get a version number, or can you tell if
it is Professional, Server, Advanced Server, Datacenter Server.
 
M

Mattias Sjögren

E.g. for windows 2000 do you just get a version number, or can you tell if
it is Professional, Server, Advanced Server, Datacenter Server.

Only the version number and whether it's an NT based version of
Windows (as opposed to Win9x). To differentiate between different
editions, use the GetVersionEx Win32 API function.



Mattias
 
G

Guest

I'd use something like below to get the enumerated platform ID.
It tells you whether the OS is NT or higher. One might want to
be more specific than that (or break it down further). It's more
direct thaan parsing the string (5.1 is really the platform ID of
Win32NT/enum)

The meaning of the platform ID enum is

Win32NT
Supported by the .NET Compact Framework.
The operating system is Windows NT or later.

Win32S
Supported by the .NET Compact Framework.
The operating system is Win32s. Win32s is a layer that runs on 16-bit
versions of Windows to provide access to 32-bit applications.

Win32Windows
Supported by the .NET Compact Framework.
The operating system is Windows 95 or later.

WinCE
Supported by the .NET Compact Framework.
The operating system is Windows CE .NET.

Here's a VB .NET sample to read it:

Private Environment As System.Environment
--------------------------

Dim OpSystem As OperatingSystem
Dim PlatformID As PlatformID


OpSystem = Environment.OSVersion
PlatformID = OpSystem.Platform
 
G

Guest

I think its poor that Environment.OSVersion doesn't have all the information
in.
It looks like you have to use Win32 API calls with OSVERSIONINFOEX as in the
following microsoft article:

http://msdn.microsoft.com/library/default.asp?url=/archive/en-us/dnaraskdr/html/askgui06042002.asp

now I just need to find out what the major/minor version numbers will be for
Win 2003.
Its ugly code having to hard-code it. What happens when the next version of
windows comes along? You'll have to keep updating your code.
 

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