views:

61

answers:

4

I am using VB .Net 2.0. I know I can detect the OS using

System.Environment.OSVersion

Can anyone tell me if there's a list somewhere where I can find what that generates for different OS versions.

Specifically I am trying to detect if a user is running Windows 7 64-bit.

A: 

Use:

Environment.OSVersion.ToString()

This will return values like:

"Microsoft Windows NT 5.0.2195.0"

Here is a link on how to extract the OS from the version/build numbers.

Or you can use this function:

Public Function GetOSVersion() As String
    Select Case Environment.OSVersion.Platform
        Case PlatformID.Win32S
            Return "Win 3.1"
        Case PlatformID.Win32Windows
            Select Case Environment.OSVersion.Version.Minor
                Case 0
                    Return "Win95"
                Case 10
                    Return "Win98"
                Case 90
                    Return "WinME"
                Case Else
                    Return "Unknown"
            End Select
        Case PlatformID.Win32NT
            Select Case Environment.OSVersion.Version.Major
                Case 3
                    Return "NT 3.51"
                Case 4
                    Return "NT 4.0"
                Case 5
                    Select Case _
                        Environment.OSVersion.Version.Minor
                        Case 0
                            Return "Win2000"
                        Case 1
                            Return "WinXP"
                        Case 2
                            Return "Win2003"
                    End Select
                Case 6
                    Return "Vista/Win2008Server"
                Case Else
                    Return "Unknown"
            End Select
        Case PlatformID.WinCE
            Return "Win CE"
    End Select
End Function
Tom Gullen
A: 

For a list of versions see here: http://www.nirmaltv.com/2009/08/17/windows-os-version-numbers/

To find out 32 vs 64 bit, see this previous question: http://stackoverflow.com/questions/336633/how-to-detect-windows-64-bit-platform-with-net

ho1
A: 

The most comprehensive solution for this I've found is PJ Naughter's DtWinver class. It can distinguish between editions of Windows (Starter Edition, Home Basic, Home Premium, Professional, Enterprise, etc.), which admittedly might be functionality you don't need.

jeffm