Results 1 to 5 of 5

Thread: Win95/98 or WinNT??

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    4

    Post

    I need a program to be able to tell if it is being run in Windows NT or not. Is there an API that can tell me this?

  2. #2
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Galway, Ireland
    Posts
    316

    Post

    Try this I nicked it from the about wizard

    [email protected]

    rc = RegQueryValueEx(hKey, SubKeyRef, 0, _
    KeyValType, tmpVal, KeyValSize) ' Get/Create Key Value

    If (rc <> ERROR_SUCCESS) Then GoTo GetKeyError ' Handle Errors

    If (Asc(Mid(tmpVal, KeyValSize, 1)) = 0) Then
    ' Win95
    Else ' WinNT
    endif

  3. #3
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    There is an API to get the paltform version:

    Code:
    Private 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
    Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
    Private Const VER_PLATFORM_WIN32s = 0
    Private Const VER_PLATFORM_WIN32_WINDOWS = 1
    Private Const VER_PLATFORM_WIN32_NT = 2
    
    '---------Put this on any event you want
    
        Dim os As OSVERSIONINFO
        Dim lret As Long
        
        lret = GetVersionEx(os)
        If lret <> 0 Then
            Select Case os.dwPlatformId
                Case VER_PLATFORM_WIN32s
                    MsgBox "Window3.1/3.11"
                Case VER_PLATFORM_WIN32_WINDOWS
                    MsgBox "Window95/98"
                Case VER_PLATFORM_WIN32_NT
                    MsgBox "WindowNT"
            End Select
        Else
            MsgBox "Error retrieving platform version."
        End If
    ------------------

    Serge

    Software Developer
    [email protected]
    [email protected]
    ICQ#: 51055819



    [This message has been edited by Serge (edited 11-18-1999).]

  4. #4

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    4

    Post

    Thanks guys. I knew this one would be an easy one for the likes of you VBPros. Thanks again.

  5. #5

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    4

    Post

    I don't suppose any would still be interested in this topic as at this late date it is now relegated to the antiquated page 3, but here goes...

    I tried solution #2 because I did not want to get in to registry keys and stuff. There was one step missing between assigning the return value of the API to a variable:

    lret = GetVersionEx(os)

    and:

    Select case os.dwPlatformId

    I found the missing step in Dan Appleman's guide to the windows API. You must first set the size of the OSVERSIONINFO Type:

    os.dwOSVersionInfoSize = SIZE_OF_OSVERSIONINFO

    where SIZE_OF_OSVERSIONINFO = 148.

    If you don't do this, all values return as 0.

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