crenaud76
Messages postés4172Date d'inscriptionmercredi 30 juillet 2003StatutMembreDernière intervention 9 juin 200628 12 oct. 2005 à 19:36
Voici un extrait de l'API-Guide
Private Declare Function GetVersion Lib "kernel32" () As Long
Public Function GetWinVersion() As String
Dim Ver As Long, WinVer As Long
Ver = GetVersion()
WinVer = Ver And &HFFFF&
'retrieve the windows version
GetWinVersion = Format((WinVer Mod 256) + ((WinVer \ 256) / 100), "Fixed")
End Function
Private Sub Form_Load()
'KPD-Team 1999
'URL: http://www.allapi.net/ 'E-Mail: KPDTeam@Allapi.net
MsgBox "Windows version: " + GetWinVersion
End Sub
cs_rt15
Messages postés3874Date d'inscriptionmardi 8 mars 2005StatutModérateurDernière intervention 7 novembre 201413 12 oct. 2005 à 20:00
Réponse de zipro4012:
VB6 ou VB.NET ?
En VB6 -> "Microsoft SysInfo Control 5.0"
En VB.NET -> Espace de nom "System.Environment.OSVersion
Sous VB6:
SysInfo1.OSVersion
====================================================================
Réponse de Renfield:
API GetWindowsVersion, BruNews précise que GetWindowsVersionEx donne plus d'infos.
Private Declare Function GetVersion Lib "kernel32" () As Long
Public 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
Public Function GetOSName(Optional Version As String) As String
If Len(Version) = 0 Then
Version = GetWindowsVersion
End If
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
Private Sub Form_Load()
MsgBox "Windows Version: " + GetWindowsVersion
MsgBox "Windows Name : " + GetOSName
End Sub