how to check if user is running Vista or XP
Hi How can I check if user running my application is running Vista or XP? I need to make it If XP then msgbox "XP" else if Vista then msgbox "Vis开发者_开发百科ta" endif
Thanks
Here is the Microsoft KB article on how to do this in C#. The code shouldn't be too hard to translate into VB.NET:
How to determine the Windows version by using Visual C#
Here's a quick attempt at conversion:
Dim osInfo As System.OperatingSystem = System.Environment.OSVersion
Select Case osInfo.Version.Major
Case 5
' Windows 2000 or XP
Case 6
' Windows Vista
End Select
Use System.Environment.OSVersion, http://msdn.microsoft.com/en-us/library/ms724832%28VS.85%29.aspx
You could take a look at the OSVersion property.
This is Justin Niessner's answer in 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
You can find the OS versions here. If you want a bit more refinement, you can add another case select where you replace System.Environment.OSVersion.Version.Major with System.Environment.OSVersion.Version.Minor to distinguish say Vista from 7. Eg:
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
精彩评论