Results 1 to 9 of 9

Thread: Everyone please read this

  1. #1

    Thread Starter
    Hyperactive Member Dmitri K's Avatar
    Join Date
    Sep 2002
    Location
    West Palm Beach, FL
    Posts
    444

    Everyone please read this

    This code is from API-Guide
    Code:
    Private Declare Function GetVersion Lib "kernel32" () As Long
    Public Function GetWinVersion() As String
        Dim Ver As Long, WinVer As Long
        Ver = GetVersion()
        WinVer = Ver And &HFFFF&
        'retrieve the windows version
        GetWinVersion = Format((WinVer Mod 256) + ((WinVer \ 256) / 100), "Fixed")
    End Function
    Private Sub Form_Load()
        'KPD-Team 1999
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        MsgBox "Windows version: " + GetWinVersion
    End Sub
    Problem is, what number does it return on the following OSes:
    Windows 95 =
    Windows 95 w/USB support =
    Windows 98 =
    Windows 98 SE =
    Windows ME =
    Windows NT =
    Windows 2k =
    Windows XP = 5.01 (what mine returned, is it same for home and pro?)

    If somebody runs any version shown above, can you please run the code and post a reply with your windows version and the number it gave. If i missed any windows version, sorry about that, but I don't think I did.

  2. #2
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631
    Please rate my post.

  3. #3
    Frenzied Member Microbasic's Avatar
    Join Date
    Mar 2001
    Posts
    1,402
    For Windows 98, it's 4.10

    I can try to recite some of the others for you:

    Windows 95: 4.10
    Windows 3.1: 3.10
    Windows 2k: 5.00
    Windows NT 4: 4.00

    The GetVersion API has been superceded with the GetVersionEx API. If you need the build number (e.g. 4.10.1995 or 4.10.1998), then you ight want to use GetVersionEx instead of GetVersion.


    MicroBasic
    Dragon Shadow Trainer

    There is no good or evil in the world...only programmers and fools .

  4. #4
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    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
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  5. #5

    Thread Starter
    Hyperactive Member Dmitri K's Avatar
    Join Date
    Sep 2002
    Location
    West Palm Beach, FL
    Posts
    444
    Oh that sucks, so Win95 and Win98 are the same number? That's the main reason I need this, to distinguish between Win95 and all others. Is there any other way to see if computer is running Windows 95 (it's for CreateWaitableTimer API, which only works on Windows 98 and later).

  6. #6

    Thread Starter
    Hyperactive Member Dmitri K's Avatar
    Join Date
    Sep 2002
    Location
    West Palm Beach, FL
    Posts
    444

  7. #7
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631
    Getting the System Version

    That article ought to help you out a little more. Shows how to distinguish a lot more.
    Please rate my post.

  8. #8

    Thread Starter
    Hyperactive Member Dmitri K's Avatar
    Join Date
    Sep 2002
    Location
    West Palm Beach, FL
    Posts
    444
    Can someone test this out for me on Windows 95, 98, ME and 2k. Let me know if it works, it should. I just converted this from MSDN article and cutted out some detailed info parts. I just need basic version info.
    Code:
    Option Explicit
    
    Public Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
    
    Public Type OSVERSIONINFO
            dwOSVersionInfoSize As Long
            dwMajorVersion As Long
            dwMinorVersion As Long
            dwBuildNumber As Long
            dwPlatformId As Long
            szCSDVersion As String * 128      '  Maintenance string for PSS usage
    End Type
    
    Const VER_PLATFORM_WIN32s = 0
    Const VER_PLATFORM_WIN32_WINDOWS = 1
    Const VER_PLATFORM_WIN32_NT = 2
    
    Public Function GetWindowsVersion() As String
    Dim ret As String
    Dim osvi As OSVERSIONINFO
    
        osvi.dwOSVersionInfoSize = Len(osvi)
    
        If Not GetVersionEx(osvi) Then ret = "GetWindowsVersion Failed"
    
        Select Case osvi.dwPlatformId
            Case VER_PLATFORM_WIN32_NT:
                If osvi.dwMajorVersion = 5 And osvi.dwMinorVersion = 2 Then ret = "Microsoft Windows, Windows Server 2003, 2003 family"
                If osvi.dwMajorVersion = 5 And osvi.dwMinorVersion = 1 Then ret = "Microsoft Windows XP"
                If osvi.dwMajorVersion = 5 And osvi.dwMinorVersion = 0 Then ret = "Microsoft Windows 2000"
                If osvi.dwMajorVersion <= 4 Then ret = "Microsoft Windows NT"
                
            Case VER_PLATFORM_WIN32_WINDOWS:
                If osvi.dwMajorVersion = 4 And osvi.dwMinorVersion = 0 Then ret = "Microsoft Windows 95"
                If osvi.dwMajorVersion = 4 And osvi.dwMinorVersion = 10 Then ret = "Microsoft Windows 98"
                If osvi.dwMajorVersion = 4 And osvi.dwMinorVersion = 90 Then ret = "Microsoft Windows Millennium Edition"
        
            Case VER_PLATFORM_WIN32s:
                ret = "Microsoft Win32s"
                
        End Select
    
    GetWindowsVersion = ret
    End Function
    call it with msgbox GetWindowsVersion

    Thanks a lot!
    Last edited by Dmitri K; Feb 4th, 2003 at 12:18 AM.

  9. #9
    Frenzied Member Shawn N's Avatar
    Join Date
    Dec 2001
    Location
    Houston
    Posts
    1,631
    Returns correctly on XP.
    Please rate my post.

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