PDA

Vollständige Version anzeigen : aktuelles Betriebssystem


Ralf Pfiffer
19.11.2000, 10:40
Hallo,

weiß jemand von euch, wie man mittels VBA das aktuelle Betriebssystem des PC ermittelt

vielen dank für eure antworten
Ralf

Manuela Kulpa
19.11.2000, 15:55
Hallo Ralf!

Zum Beispiel so:

Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type


Public Sub InfoBS()

Dim OSInfo As OSVERSIONINFO, PId As String, Ret As Long


'Set the structure size
OSInfo.dwOSVersionInfoSize = Len(OSInfo)
'Get the Windows version
Ret = GetVersionEx(OSInfo)
'Chack for errors
If Ret = 0 Then MsgBox "Error Getting Version Information": Exit Sub
'Print the information to the form
Select Case OSInfo.dwPlatformId
Case 0
PId = "Windows 32s "
Case 1
PId = "Windows 95/98"
Case 2
PId = "Windows NT "
End Select

Debug.Print "OS: " + PId
Debug.Print "Win version:" + str$(OSInfo.dwMajorVersion) + "." + LTrim(str(OSInfo.dwMinorVersion))
Debug.Print "Build: " + str(OSInfo.dwBuildNumber)

End Sub

Aufruf: Call InfoBS!

LLAP