Recherche
Recherche
Les mémos
Je débute...
Visites

 1000692 visiteurs

 2 visiteurs en ligne

Version de Windows

'/
'/ A placer dans la partie déclarative
'/
'Version du système d'exploitation
Private Declare Function GetVersionExA Lib "kernel32" _
                     (lpVersionInformation As OSVERSIONINFO) As Integer

Private Type OSVERSIONINFO
    dwOSVersionInfoSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    szCSDVersion As String * 128
End Type

La fonction :

Public Function GetVersNumber() As Long
    Dim osinfo As OSVERSIONINFO
    Dim retvalue As Integer
    osinfo.dwOSVersionInfoSize = 148
    osinfo.szCSDVersion = Space$(128)
    retvalue = GetVersionExA(osinfo)

    With osinfo
        Select Case .dwPlatformId
        Case 1
            Select Case .dwMinorVersion
            Case 0
                GetVersNumber = 1            ' Windows 95
            Case 10
                GetVersNumber = 2            ' Windows 98
            Case 90
                GetVersNumber = 3            ' Windows Me
            End Select

        Case 2
            Select Case .dwMajorVersion
            Case 0
                GetVersNumber = 6            ' Windows NT 3.51
            Case 4
                GetVersNumber = 7            ' Windows NT 4.0
            Case 5
                If .dwMinorVersion = 0 Then
                    GetVersNumber = 4          ' Windows 2000
                Else
                    GetVersNumber = 5          ' Windows XP
                End If
            Case 6
                If .dwMinorVersion = 0 Then
                    GetVersNumber = 8          ' Vista
                Else
                    GetVersNumber = 9          ' Win 7
                End If
            End Select
        Case Else
            GetVersNumber = 10      ' Failed
        End Select
    End With
End Function


Catégorie : Les mémos - Administration
Page lue 6537 fois