|
-
Apr 2nd, 2002, 12:05 PM
#1
Detecting Windows Version
VB Code:
'constants returned by OperatingSystem
Global Const Windows95 As Integer = 95
Global Const Windows98 As Integer = 98
Global Const WindowsNT3 As Integer = 3 'v3.51
Global Const WindowsNT4 As Integer = 4
Private Type OSVersionInfo
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformID As Long
szCSDVersion As String * 128
End Type
Private Declare Function GetVersionExA Lib "kernel32" (lpVersionInformation As OSVersionInfo) As Integer
Public Function OperatingSystem() As Integer
Dim OSInfo As OSVersionInfo
Dim RetValue As Integer
OSInfo.dwOSVersionInfoSize = 148
OSInfo.szCSDVersion = Space$(128)
RetValue = GetVersionExA(OSInfo)
With OSInfo
Select Case .dwPlatformID
Case 1
If .dwMinorVersion = 0 Then
OperatingSystem = Windows95
ElseIf .dwMinorVersion = 10 Then
OperatingSystem = Windows98
End If
Case 2
If .dwMajorVersion = 3 Then
OperatingSystem = WindowsNT3
ElseIf .dwMajorVersion = 4 Then
OperatingSystem = WindowsNT4
End If
Case Else
OperatingSystem = 0
End Select
End With
End Function
Private Sub Form_Load()
If OperatingSystem = Windows98 Then Image1.Visible = True
End Sub
How do you add Windows XP to that code?
-
Apr 2nd, 2002, 12:24 PM
#2
.dwMajorVersion = 5 ' win2K or XP
.dwMinorVersion = 0 ' Win 2000
.dwMinroVersion = 1 ' Win XP
-
Apr 2nd, 2002, 12:31 PM
#3
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
-
Apr 2nd, 2002, 12:47 PM
#4
Jim: Do you happen to know what the Build Number for XP is?
-
Apr 2nd, 2002, 02:18 PM
#5
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?
-
Apr 2nd, 2002, 02:23 PM
#6
Originally posted by jim mcnamara
You do know that the build number isn't necessarily constant?
Yep...but then, why would we expect consistency?
-
Apr 2nd, 2002, 02:29 PM
#7
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|