Salut j'ai trouvé ce bout de code dans le bouquin de VB6 edition Micro application, je l'ai tester et elle marche bien sur W98,WNT,W2000
'delcaration de l'api Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As Osversioninfo) As Long
'declaration de la structure
Type Osversioninfo dwOSVersioninfo As Long dwMajorversion As Long dwMinorversion As Long dwBuildnumber As Long dwPlatformid As Long szCSDVersion As String * 128 End Type 'declaration des constantes Public Const VER_PLATEFORM_WIN32_NT = 2 Public Const VER_PLATEFORM_WIN32_WINDOWS = 1 Public Const VER_PLATEFORM_WIN32S = 0
Public Sub versionOS(Plateform$, version$, info$) 'info système Dim vInfo As Osversioninfo vInfo.dwOSVersioninfo = Len(vInfo) If GetVersionEx(vInfo) <> 0 Then 'plateform Select Case vInfo.dwPlatformid Case VER_PLATEFORM_WIN32_NT Plateform$ = "Windows NT" Case VER_PLATEFORM_WIN32_WINDOWS Plateform$ = "Windows 95" Case VER_PLATEFORM_WIN32S Plateform$ = "Windows 3.1" End Select 'infos complementaires info$ = vInfo.szCSDVersion 'version/sous version Ma$ = Trim$(Str$(vInfo.dwMajorversion)) MI$ = Trim$(Str$(vInfo.dwMinorversion)) If Len(MI$) Then MI$ = "0" + MI$ End If 'build If vInfo.dwPlatformid = VER_PLATEFORM_WIN32_NT Then 'windows nt b$ = vInfo.dwBuildnumber Else 'win95 poid faible. On masque le bit de poid fort b$ = vInfo.dwBuildnumber And &HFFFF& End If version$ = Ma$ + "." + MI$ + "." + b$ 'info complementaires info$ = vInfo.szCSDVersion If Left$(info$, 1) = Chr$(0) Then info$ = "absent"
'affichage dans pour la messageBox
T$ = "système d'exploitation" M$ = "système :" + Plateform$ + vbCrLf M$ = M$ + "Version : " + version$ + vbCrLf M$ = M$ + "Autres informations : " + info$ + vbCrLf
MsgBox M$, vbInformation, T$
End Sub
'appel de la fonction versionos plateform$,version,info$
------------------------------- Réponse au message : -------------------------------
Bonjour,
Qui peux me donner le code qui utilise l'API Getversionex() et qui retourne le systéme d'expploitation utilisé (win95/98/2000/NT).
Bien sûr un code vb qui marche.
D'avance merci
|