Cherche bou de codes pour savoir système d'exploitation de l'utilisateur

cs_ab44 Messages postés 79 Date d'inscription lundi 28 mars 2005 Statut Membre Dernière intervention 4 juin 2012 - 24 juil. 2005 à 19:57
Zlub Messages postés 809 Date d'inscription mercredi 11 octobre 2000 Statut Membre Dernière intervention 29 septembre 2010 - 26 juil. 2005 à 04:54
je cherche un bout de code pour savoir le système d'exploitation utilisé par l'utilisateur

et aussi un autre code pour passer a la ligne ds une textbox
j'attens vos réponses .

a +

5 réponses

Zlub Messages postés 809 Date d'inscription mercredi 11 octobre 2000 Statut Membre Dernière intervention 29 septembre 2010 8
24 juil. 2005 à 20:05
Salut,


Ce source est disponible sur le site #7443

Essais de faire des recherches avant de poster sur le forum ;)

++

Zlub
0
Gobillot Messages postés 3140 Date d'inscription vendredi 14 mai 2004 Statut Membre Dernière intervention 11 mars 2019 34
24 juil. 2005 à 21:00
Private Type OSVERSIONINFO

dwOSVersionInfoSize As Long

dwMajorVersion As Long

dwMinorVersion As Long

dwBuildNumber As Long

dwPlatformId As Long

szCSDVersion As String * 128

wServicePackMajor As Long

wServicePackMinor As Long

End Type



Private Declare Function GetVersion Lib "kernel32" () As Long

Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long



Private Sub Command1_Click()

Dim OS As OSVERSIONINFO

Dim PId As String

Dim Ver As String

Dim R As Long



R = GetVersion

Text1 = Hex$(R)



OS.dwOSVersionInfoSize = Len(OS)

R = GetVersionEx(OS)

Ver = (OS.dwMajorVersion) & "." & (OS.dwMinorVersion)

Select Case OS.dwPlatformId

Case 0: PId = "Windows 32s "

Case 1:

If OS.dwMinorVersion < 10 Then


If OS.dwBuildNumber = 950 Then


PId = "Windows 95"


End If


If OS.dwBuildNumber >= 951 Or OS.dwBuildNumber <= 1080 Then


PId = "Windows 95 SP1"


End If


If OS.dwBuildNumber >= 1081 Then


PId = "Windows 95 OSR2"


End If

End If

If OS.dwMinorVersion = 10 Then


If OS.dwBuildNumber = 1998 Then


PId = "Windows 98"


End If


If OS.dwBuildNumber >= 1999 Or OS.dwBuildNumber <= 2182 Then


PId = "Windows 98 SP1"


End If


If OS.dwBuildNumber >= 2183 Then


PId = "Windows 98 SE"


End If

End If

If OS.dwMinorVersion > 10 Then

PId = "Windows ME"

End If

Case 2:

Select Case Ver

Case "5.0": PId = "Windows 2000"

Case "5.1": PId = "Windows XP"


Case Else: PId = "Windows NT " & Ver

End Select

Case 3:

If OS.dwMajorVersion = 1 Then


PId = "Windows CE 1.0"

End If

If OS.dwMajorVersion = 2 Then


If OS.dwMinorVersion = 0 Then


PId = "Windows CE 2.0"


Else


PId = "Windows CE 2.1"


End If

End If

If OS.dwMajorVersion > 2 Then


PId = "Windows CE 3.0"

End If

Case Else:

PId = "Unable To get Windows Version"

End Select

Text2 = Hex$(R) & vbCrLf

Text2 = Text2 & "OS.........: " & PId & vbCrLf

Text2 = Text2 & "version....: " & Ver & vbCrLf

Text2 = Text2 & "Build......: " & CStr(OS.dwBuildNumber) & vbCrLf

Text2 = Text2 & OS.szCSDVersion

MsgBox OS.wServicePackMajor

MsgBox OS.wServicePackMinor

End Sub


Daniel
0
cs_ab44 Messages postés 79 Date d'inscription lundi 28 mars 2005 Statut Membre Dernière intervention 4 juin 2012
24 juil. 2005 à 22:02
je n'ai pas trop bien compris
en faite je voudrais une msgbox qui me dit si c'est xp ou 95, 98...
je ne comprend pas les nombres ds les msgbox

merci a vous Zlub et Gobillot
0
Zlub Messages postés 809 Date d'inscription mercredi 11 octobre 2000 Statut Membre Dernière intervention 29 septembre 2010 8
24 juil. 2005 à 22:52
Salut,



Je ne vois aps trop se qui de déroute, tu as tout se dont tu as besoin... mais bon oki, faut adapter un peu ...


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

Private Declare Function GetVersion Lib "kernel32" () As Long
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long




public Function OsVersion()

Dim OS As OSVERSIONINFO
Dim PId As String
Dim Ver As String
Dim R As Long



OS.dwOSVersionInfoSize = Len(OS)
R = GetVersionEx(OS)
Ver = (OS.dwMajorVersion) & "." & (OS.dwMinorVersion)
Select Case OS.dwPlatformId
Case 0: PId = "Windows 32s "
Case 1:
If OS.dwMinorVersion < 10 Then


If OS.dwBuildNumber = 950 Then


PId = "Windows 95"


End If


If OS.dwBuildNumber >= 951 Or OS.dwBuildNumber <= 1080 Then


PId = "Windows 95 SP1"


End If


If OS.dwBuildNumber >= 1081 Then


PId = "Windows 95 OSR2"


End If
End If
If OS.dwMinorVersion = 10 Then


If OS.dwBuildNumber = 1998 Then


PId = "Windows 98"


End If


If OS.dwBuildNumber >= 1999 Or OS.dwBuildNumber <= 2182 Then


PId = "Windows 98 SP1"


End If


If OS.dwBuildNumber >= 2183 Then


PId = "Windows 98 SE"


End If
End If
If OS.dwMinorVersion > 10 Then
PId = "Windows ME"
End If
Case 2:
Select Case Ver
Case "5.0": PId = "Windows 2000"
Case "5.1": PId = "Windows XP"


Case Else: PId = "Windows NT " & Ver
End Select
Case 3:
If OS.dwMajorVersion = 1 Then


PId = "Windows CE 1.0"
End If
If OS.dwMajorVersion = 2 Then


If OS.dwMinorVersion = 0 Then


PId = "Windows CE 2.0"


Else


PId = "Windows CE 2.1"


End If
End If
If OS.dwMajorVersion > 2 Then


PId = "Windows CE 3.0"
End If
Case Else:
PId = " Version de Windows Inconnue"
End Select

OsVersion = PId

End Function


' Appel

MsgBox " L'OS tourne sous " & OsVersion()





ça te vas ainsi ?



++

Zlub
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
Zlub Messages postés 809 Date d'inscription mercredi 11 octobre 2000 Statut Membre Dernière intervention 29 septembre 2010 8
26 juil. 2005 à 04:54
Salut,

Sinon le source (lien) que je t'ai passé est facilement adaptable à ton idée :



rivate Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long

Private Const VER_PLATFORM_WIN32s = 0

Private Const VER_PLATFORM_WIN32_WINDOWS = 1

Private Const VER_PLATFORM_WIN32_NT = 2

Private Type OSVERSIONINFO

dwOSVersionInfoSize As Long

dwMajorVersion As Long

dwMinorVersion As Long

dwBuildNumber As Long

dwPlatformId As Long

szCSDVersion As String * 128

wSPMajor As Integer

End Type



Public Function GetVersion() As String

Dim myVer As OSVERSIONINFO

Dim dl&

myVer.dwOSVersionInfoSize = 148

dl& = GetVersionEx&(myVer)

If myVer.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then

If myVer.dwMajorVersion 4 And myVer.dwMinorVersion 0 Then

If myVer.dwBuildNumber = 950 Then

GetVersion = "Win95"

Else

GetVersion = "Win95OSR2"

End If

ElseIf myVer.dwMajorVersion 4 And myVer.dwMinorVersion 10 Then

If myVer.dwBuildNumber = 1998 Then

GetVersion = "Win98"

Else

GetVersion = "Win98SE"

End If

ElseIf myVer.dwMajorVersion >= 4 And myVer.dwMinorVersion > 10 Then

GetVersion = "WinME"

End If

ElseIf myVer.dwPlatformId = VER_PLATFORM_WIN32_NT Then

If myVer.dwMajorVersion 3 And myVer.dwMinorVersion 0 Then

GetVersion = "WinNT3_0"

ElseIf myVer.dwMajorVersion 3 And myVer.dwMinorVersion 1 Then

GetVersion = "WinNT3_1"

ElseIf myVer.dwMajorVersion 3 And myVer.dwMinorVersion 5 Then

GetVersion = "WinNT3_5"

ElseIf myVer.dwMajorVersion = 4 Then

GetVersion = "WinNT4"

ElseIf myVer.dwMajorVersion 5 And myVer.dwMinorVersion 0 Then

GetVersion = "Win2k"

ElseIf myVer.dwMajorVersion 5 And myVer.dwMinorVersion 1 Then

GetVersion = "WinXP"

End If

End If

End Function

En bleu les modifs ... franchement c'est pas la mort ...



et pour coller pile poil avec ta demande



Public Function GetVersionCourte() As String

Dim myVer As OSVERSIONINFO

Dim dl&

myVer.dwOSVersionInfoSize = 148

dl& = GetVersionEx&(myVer)

If myVer.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then

If myVer.dwMajorVersion 4 And myVer.dwMinorVersion 0 Then

GetVersion = "95"

ElseIf myVer.dwMajorVersion 4 And myVer.dwMinorVersion 10 Then

GetVersion = "98"

ElseIf myVer.dwMajorVersion >= 4 And myVer.dwMinorVersion > 10 Then

GetVersion = "ME"

End If

ElseIf myVer.dwPlatformId = VER_PLATFORM_WIN32_NT Then

If myVer.dwMajorVersion = 3 Then

GetVersion = "NT 3"

ElseIf myVer.dwMajorVersion = 4 Then

GetVersion = "NT 4"

ElseIf myVer.dwMajorVersion 5 And myVer.dwMinorVersion 0 Then

GetVersion = "2000"

ElseIf myVer.dwMajorVersion 5 And myVer.dwMinorVersion 1 Then

GetVersion = "XP"

End If

End If

End Function



Voilà comme ça tu as deux versions...
++

Zlub
0
Rejoignez-nous