Results 1 to 7 of 7

Thread: Detecting Windows Version

  1. #1
    Shady009
    Guest

    Detecting Windows Version

    VB Code:
    1. 'constants returned by OperatingSystem
    2. Global Const Windows95 As Integer = 95
    3. Global Const Windows98 As Integer = 98
    4. Global Const WindowsNT3 As Integer = 3 'v3.51
    5. Global Const WindowsNT4 As Integer = 4
    6.  
    7.  
    8. Private Type OSVersionInfo
    9.    dwOSVersionInfoSize As Long
    10.    dwMajorVersion As Long
    11.    dwMinorVersion As Long
    12.    dwBuildNumber As Long
    13.    dwPlatformID As Long
    14.    szCSDVersion As String * 128
    15. End Type
    16.  
    17. Private Declare Function GetVersionExA Lib "kernel32" (lpVersionInformation As OSVersionInfo) As Integer
    18.  
    19. Public Function OperatingSystem() As Integer
    20. Dim OSInfo As OSVersionInfo
    21. Dim RetValue As Integer
    22.  
    23. OSInfo.dwOSVersionInfoSize = 148
    24. OSInfo.szCSDVersion = Space$(128)
    25. RetValue = GetVersionExA(OSInfo)
    26.  
    27. With OSInfo
    28. Select Case .dwPlatformID
    29.    Case 1
    30.       If .dwMinorVersion = 0 Then
    31.          OperatingSystem = Windows95
    32.       ElseIf .dwMinorVersion = 10 Then
    33.          OperatingSystem = Windows98
    34.       End If
    35.    Case 2
    36.       If .dwMajorVersion = 3 Then
    37.          OperatingSystem = WindowsNT3
    38.       ElseIf .dwMajorVersion = 4 Then
    39.          OperatingSystem = WindowsNT4
    40.       End If
    41.    Case Else
    42.       OperatingSystem = 0
    43. End Select
    44. End With
    45. End Function
    46.  
    47. Private Sub Form_Load()
    48. If OperatingSystem = Windows98 Then Image1.Visible = True
    49. End Sub

    How do you add Windows XP to that code?

  2. #2
    jim mcnamara
    Guest
    .dwMajorVersion = 5 ' win2K or XP
    .dwMinorVersion = 0 ' Win 2000
    .dwMinroVersion = 1 ' Win XP

  3. #3
    Shady009
    Guest
    Originally posted by jim mcnamara
    .dwMajorVersion = 5 ' win2K or XP
    .dwMinorVersion = 0 ' Win 2000
    .dwMinroVersion = 1 ' Win XP
    Thanks a lot but I noticed that you've made a mistake. You wrote Minro instead of Minor

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Jim: Do you happen to know what the Build Number for XP is?

  5. #5
    jim mcnamara
    Guest
    I don't know the build number. When I get onto one of the XP boxes I'll find out.

    You do know that the build number isn't necessarily constant?

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Originally posted by jim mcnamara
    You do know that the build number isn't necessarily constant?
    Yep...but then, why would we expect consistency?

  7. #7
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    i can check when i get home.. i am runnin xp professional enterprise edition... thanks to my job

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width