Results 1 to 4 of 4

Thread: "GetVersionEx" API help

  1. #1

    Thread Starter
    Hyperactive Member zer0_flaw's Avatar
    Join Date
    Apr 2001
    Posts
    448

    "GetVersionEx" API help

    I'm using the following API:
    Code:
    Declare Function GetVersionEx Lib "kernel32.dll" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
    I 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

  2. #2
    jim mcnamara
    Guest
    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.

  3. #3
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Here is an example:
    VB Code:
    1. Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
    2. Private Type OSVERSIONINFO
    3.     dwOSVersionInfoSize As Long
    4.     dwMajorVersion As Long
    5.     dwMinorVersion As Long
    6.     dwBuildNumber As Long
    7.     dwPlatformId As Long
    8.     szCSDVersion As String * 128
    9. End Type
    10. Private Sub Form_Load()
    11.     Dim OSInfo As OSVERSIONINFO, PId As String
    12. 'Set the graphical mode to persistent
    13.     Me.AutoRedraw = True
    14.     'Set the structure size
    15.     OSInfo.dwOSVersionInfoSize = Len(OSInfo)
    16.     'Get the Windows version
    17.     Ret& = GetVersionEx(OSInfo)
    18.     'Chack for errors
    19.     If Ret& = 0 Then MsgBox "Error Getting Version Information": Exit Sub
    20.     'Print the information to the form
    21.     Select Case OSInfo.dwPlatformId
    22.         Case 0
    23.             PId = "Windows 32s "
    24.         Case 1
    25.             PId = "Windows 95/98"
    26.         Case 2
    27.             PId = "Windows NT "
    28.     End Select
    29.     Print "OS: " + PId
    30.     Print "Win version:" + str$(OSInfo.dwMajorVersion) + "." + LTrim(str(OSInfo.dwMinorVersion))
    31.     Print "Build: " + str(OSInfo.dwBuildNumber)
    32. End Sub
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  4. #4

    Thread Starter
    Hyperactive Member zer0_flaw's Avatar
    Join Date
    Apr 2001
    Posts
    448
    Thanks Vlatko... that helped a lot

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