Betriebssystem ermitteln
[Windows 95/98/NT/ME/2000]

15.03.2001


Ermitteln Sie, auf welchem Betriebssystem Ihr Programm läuft:
    Update am 15.03.2001: Windows ME wird nun auch erkannt.

ERFORDERLICHE OBJEKTE
   keine

 FORM-CODE   
   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
   Const VER_PLATFORM_WIN32s = 0
   Const VER_PLATFORM_WIN32_WINDOWS = 1
   Const VER_PLATFORM_WIN32_NT = 2
   Function Betriebssystem()
      Dim OSString$, OSVersion As OSVERSIONINFO, BuildNr&
      OSVersion.dwOSVersionInfoSize = Len(OSVersion)
      Call GetVersionEx(OSVersion)
      OSString = "unbekanntes Betriebssystem"
      With OSVersion
         If (.dwBuildNumber And &HFFFF&) > &H7FFF Then
            BuildNr = (.dwBuildNumber And &HFFFF&) - &H10000
         Else
            BuildNr = .dwBuildNumber And &HFFFF&
         End If
         'Windows NT / Windows 2000
         If .dwPlatformId = VER_PLATFORM_WIN32_NT Then
            If .dwMajorVersion = 4 Then
               OSString = "Windows NT"
               ElseIf .dwMajorVersion = 5 Then OSString = "Windows 2000"
            End If
         ElseIf .dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then
            'Windows 98/ Windows 98 SE
            If (.dwMajorVersion > 4) Or (.dwMajorVersion = 4 And _
               .dwMinorVersion = 10) Then
               If BuildNr = 1998 Then
                  OSString = "Windows 98"
               Else
                  OSString = "Windows 98 SE"
               End If
            'Windows 95
            ElseIf (.dwMajorVersion = 4 And .dwMinorVersion = 0) Then
               OSString = "Windows 95"
            End If
            'Windows ME
            If (.dwMajorVersion = 4 And .dwMinorVersion = 90) Then
               OSString = "Windows ME"
            End If
         ElseIf .dwPlatformId = VER_PLATFORM_WIN32s Then
            OSString = "Windows 32s"
         End If
       End With
       Betriebssystem = OSString
   End Function
   Private Sub Form_Load()
      MsgBox Betriebssystem, vbInformation
      End
   End Sub
 

 

Download - 2 KB