Check Windows Version

SIMIN

Regular
Joined
Mar 10, 2008
Messages
92
Hello,
I want to detect if my application is running under XP, 2003 or Vista? (I know just one of these, no ther OS)
How can I detect the current version?
I have the following information but don't know how should I compare them?

Dim MyVersion As Version = Environment.OSVersion.Version
Dim XPVersion As New Version(5, 1, 0, 0)
Dim ServerVersion As New Version(5, 2, 0, 0)
Dim VistaVersion As New Version(6, 0, 0, 0)
 
To make it simple, can I say that this code is correct? I just want to detect Windows Version that's enough:
Visual Basic:
If Environment.OSVersion.Version.Major = 5 Then
    If Environment.OSVersion.Version.Minor = 1 Then
        'XP
    End If
    If Environment.OSVersion.Version.Minor = 2 Then
        '2003
    End If
End If
If Environment.OSVersion.Version.Major = 6 Then
    'Vista
End If
 
Back
Top