Visual Basic:
Select Case System.Environment.OSVersion.Version.Major
Case 5
' Windows 2000 or XP
Case 6
' Windows Vista or 7 ie. 6.0 and 6.1
End Select
Here you can find OS versions. If you want to improve a bit, you can add another case when you replace System. Environment.OSVersion.Version.Major with System.Environment.OSVersion.Version.Minor to distinguish say Vista from 7. For example:
Select Case System.Environment.OSVersion.Version.Major
Case 5
' Windows 2000 or XP
Case 6
' Windows Vista or 7 ie. 6.0 and 6.1
Select Case System.Environment.OSVersion.Version.Minor
Case 0
'Vista
Case 1
'7
End Select
End Select
source
share