How to check if a Vista or XP user is working

Hi How to check if the application is running Vista or XP? I need to do this if XP then msgbox "XP" else if Vista then msgbox "Vista" ENDIF

thank

+3
source share
4 answers

Here is a Microsoft KB article on how to do this in C #. The code should not be too complicated to translate into VB.NET:

How to determine Windows version using Visual C #

Here is a quick conversion attempt:

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
+2
source
+1
source
+1

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
0
source

Source: https://habr.com/ru/post/1766549/


All Articles