Dans un module:
Declare Function GetVersion Lib « kernel32 » () As Long
Function GetWindowsVersion() As String
Dim Version As Long: Version = GetVersion
Dim Major As Long: Major = (Version And &HFFFF&) Mod 256
Dim Minor As Long: Minor = ((Version And &HFFFF&) – Major) \ 100
Dim Build As Long: Build = (Version \ &H10000)
GetWindowsVersion = Major & « . » & Format(Minor, « 00 ») & « . » & Build
End Function
Function GetOSName(Optional Version As String) As String
If Len(Version) = 0 Then Version = GetWindowsVersion
If Version Like « 5.* » Then
GetOSName = « 2000/XP »
ElseIf Version Like « 4.1* » Then
GetOSName = « 9x »
ElseIf Version Like « 4.0* » Then
GetOSName = « NT4 »
ElseIf Version Like « 3.0* » Then
GetOSName = « NT3 »
ElseIf Version Like « 3.1* » Then
GetOSName = « 3.1 »
End If
End Function
Utilisation:
Sub Form_Load()
MsgBox « Windows Version: » + GetWindowsVersion
MsgBox « Windows Name : » + GetOSName
End Sub