Click to See Complete Forum and Search --> : "GetVersionEx" API help
zer0_flaw
Jul 5th, 2001, 11:14 PM
I'm using the following API:Declare Function GetVersionEx Lib "kernel32.dll" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As LongI was hoping it would return something like "windows 98" or "windows 95" but instead it returns the version number. I know that "4.10" is windows 98 and "4.0" is windows 95... does anyone know the number for NT, ME, 2k, etc... or does anyone know how to make it return the names like I wanted instead of the number? Any help is appreciated. Later,
-zer0 flaw
jim mcnamara
Jul 5th, 2001, 11:25 PM
Consider using the sysinfo control - it's a lot more programmer friendly.
As an aside - all operating systems do this kind of thing - return constant values. The reason is that it's more effieicent to return a 4 than a "Windows 2040". It takes less code and memory. Really the overriding consideration. Not programmer convenience.
:)
Vlatko
Jul 6th, 2001, 03:46 AM
Here is an example:
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
Private Sub Form_Load()
Dim OSInfo As OSVERSIONINFO, PId As String
'Set the graphical mode to persistent
Me.AutoRedraw = True
'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
Print "OS: " + PId
Print "Win version:" + str$(OSInfo.dwMajorVersion) + "." + LTrim(str(OSInfo.dwMinorVersion))
Print "Build: " + str(OSInfo.dwBuildNumber)
End Sub
zer0_flaw
Jul 6th, 2001, 09:58 AM
Thanks Vlatko... that helped a lot :D
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.