[AccessD] Operating System Class

MartyConnelly martyconnelly at shaw.ca
Fri May 27 21:03:18 CDT 2005


I am running Win Xp Home edition SP2 and I get hex 300 for

Case osNT.intSuiteMask
                                Case &H200
                                    OSName = "Windows XP Home Edition"



DWUTKA at marlow.com wrote:

>Just something I'm putting into a little project I'm working on.  I know
>this stuff has been asked before, so here is all sorts of stuff for the OS
>put into a handy class for ya!
>
>Option Explicit
>Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA"
>(lpVersionInformation As OSVERSIONINFO) As Long
>Private Declare Function GetVersionEx2 Lib "kernel32" Alias "GetVersionExA"
>(lpVersionInformation As OSVERSIONINFOEX) As Long
>Private Type OSVERSIONINFO
>  intOSVersionInfoSize As Long
>  intMajorVersion As Long
>  intMinorVersion As Long
>  intBuildNumber As Long
>  intPlatformId As Long
>  strCSDVersion As String * 128
>End Type
>Private Type OSVERSIONINFOEX
>  intOSVersionInfoSize As Long
>  intMajorVersion As Long
>  intMinorVersion As Long
>  intBuildNumber As Long
>  intPlatformId As Long
>  strCSDVersion As String * 128
>  intServicePackMajor As Integer
>  intServicePackMinor As Integer
>  intSuiteMask As Integer
>  bytProductType As Byte
>  bytReserved As Byte
>End Type
>Public OSType As String
>Public OSVersion As String
>Public OSBuild As Long
>Public OSName As String
>Public NTBased As Boolean
>Public NT4 As Boolean
>Public Windows2000 As Boolean
>Public WindowsXP As Boolean
>Public Windows2003 As Boolean
>Public Server As Boolean
>Public DomainController As Boolean
>Public ServicePack As String
>Dim CSDString As String
>Private Sub Class_Initialize()
>Dim os As OSVERSIONINFO
>Dim dwReturn As Long
>Dim osNT As OSVERSIONINFOEX
>os.intOSVersionInfoSize = Len(os)
>dwReturn = GetVersionEx(os)
>Server = False
>DomainController = False
>If dwReturn = 0 Then
>    OSType = "Unknown"
>    NTBased = False
>    OSName = "Unknown"
>Else
>    CSDString = os.strCSDVersion
>    CSDString = Left(Trim(UCase(CSDString)), 1)
>    If os.intPlatformId = 2 Then
>        OSType = "Windows NT"
>        NTBased = True
>    Else
>        OSType = "Windows 9x"
>        NTBased = False
>    End If
>    OSVersion = os.intMajorVersion & "." & os.intMinorVersion
>    If NTBased Then
>        OSBuild = os.intBuildNumber
>    Else
>        OSBuild = os.intBuildNumber And &HFFF
>    End If
>    Windows2000 = False
>    WindowsXP = False
>    Windows2003 = False
>    NT4 = False
>    If NTBased Then
>        osNT.intOSVersionInfoSize = Len(osNT)
>        dwReturn = GetVersionEx2(osNT)
>        ServicePack = osNT.intServicePackMajor & "." &
>osNT.intServicePackMinor
>        If dwReturn = 0 Then
>            OSName = "Error"
>        Else
>            DomainController = osNT.bytProductType = 2
>            If DomainController Then
>                Server = True
>            Else
>                Server = osNT.bytProductType = 3
>            End If
>            Select Case os.intMajorVersion
>                Case 4
>                    NT4 = True
>                    Select Case osNT.bytProductType
>                        Case 1
>                            OSName = "Windows NT 4.0 WorkStation"
>                        Case 2, 3
>                            If osNT.intSuiteMask = 2 Then
>                                OSName = "Windows NT 4.0 Server Enterprise
>Edition"
>                            Else
>                                OSName = "Windows NT 4.0 Server Standard
>Edition"
>                            End If
>                        Case Else
>                            OSName = "Windows NT 4.0"
>                    End Select
>                Case 5
>                    Select Case os.intMinorVersion
>                        Case 0
>                            Windows2000 = True
>                            Select Case osNT.bytProductType
>                                Case 1
>                                    OSName = "Windows 2000 Professional
>Edition"
>                                Case 2, 3
>                                    Select Case osNT.intSuiteMask
>                                        Case &H80
>                                            OSName = "Windows 2000 Server
>DataCenter"
>                                        Case &H2
>                                            OSName = "Windows 2000 Server
>Advanced"
>                                        Case Else
>                                            OSName = "Windows 2000 Server"
>                                    End Select
>                                Case Else
>                                    OSName = "Windows 2000"
>                            End Select
>                        Case 1
>                            WindowsXP = True
>                            Select Case osNT.intSuiteMask
>                                Case &H200
>                                    OSName = "Windows XP Home Edition"
>                                Case Else
>                                    OSName = "Windows XP Professional
>Edition"
>                            End Select
>                        Case 2
>                            Windows2003 = True
>                            Select Case osNT.intSuiteMask
>                                Case &H2
>                                    OSName = "Windows Server 2003 Enterprise
>Edition"
>                                Case &H80
>                                    OSName = "Windows Server 2003
>DataCenter"
>                                Case &H400
>                                    OSName = "Windows Server 2003 Web
>Edition"
>                                Case Else
>                                    OSName = "Windows Server 2003 Standard"
>                            End Select
>                        Case Else
>                            OSName = "Unknown NT Based OS"
>                    End Select
>            End Select
>        End If
>    Else
>        Select Case os.intMinorVersion
>            Case 0
>                 'Windows 95
>                 Select Case CSDString
>                    Case "A"
>                        OSName = "Windows 95A"
>                    Case "B"
>                        OSName = "Windows 95B OSR2"
>                    Case "C"
>                        OSName = "Windows 95C OSR2"
>                    Case Else
>                        OSName = "Windows 95"
>                End Select
>            Case 10
>                Select Case CSDString
>                    Case "A"
>                        OSName = "Windows 98 Second Edition"
>                    Case Else
>                        OSName = "Windows 98"
>                End Select
>            Case 90
>                OSName = "Windows Millenium Edition"
>            Case Else
>                OSName = "Unknown Winodows 9x"
>        End Select
>    End If
>End If
>End Sub
>  
>

-- 
Marty Connelly
Victoria, B.C.
Canada






More information about the AccessD mailing list