' Déclarations
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Private Declare Function GetVersionExA Lib "kernel32" (lpVersionInformation As OSVERSIONINFO) As Long
'
' Fonction publique à appeler
Public Function getWinVersion() As String
Dim osinfo As OSVERSIONINFO
Dim retvalue As Integer
osinfo.dwOSVersionInfoSize = 148
osinfo.szCSDVersion = Space$(128)
retvalue = GetVersionExA(osinfo)
With osinfo
Select Case .dwMajorVersion
Case 4
Select Case .dwMinorVersion
Case 0
getWinVersion = "Windows 95"
Case 10
getWinVersion = "Windows 98"
End Select
Case 5
Select Case .dwMinorVersion
Case 0
getWinVersion = "Windows 2000"
Case 1
getWinVersion = "Windows XP"
Case 2
getWinVersion = "Windows 2003"
End Select
Case 6
Select Case .dwMinorVersion
Case 0
getWinVersion = "Vista"
Case 1
getWinVersion = "Windows 7"
Case Is >= 2
getWinVersion = "Version plus récente que Windows 7"
End Select
Case Is >= 7
getWinVersion = "Version plus récente que Windows 7"
Case Else
getWinVersion = "Version de windows inconnue"
End Select
End With
End Function