Results 1 to 5 of 5

Thread: Use Api to find OS used on a PC?

  1. #1

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    Which function can I look up which can tell me what operating system the user is running on their PC.


    Thank you in advance!

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  2. #2
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    Code:
    'paste into a form with 1 command button
    Private Declare Function GetVersionExA Lib "kernel32" (lpVersionInformation As OSVERSIONINFO) As Integer
        Private Type OSVERSIONINFO
           dwOSVersionInfoSize As Long
           dwMajorVersion As Long
           dwMinorVersion As Long
           dwBuildNumber As Long
           dwPlatformId As Long
           szCSDVersion As String * 128
        End Type
          
          Public Function getVersion() As Long
             Dim osinfo As OSVERSIONINFO
             Dim retvalue As Integer
             osinfo.dwOSVersionInfoSize = 148
             osinfo.szCSDVersion = Space$(128)
             retvalue = GetVersionExA(osinfo)
             getVersion = osinfo.dwPlatformId
          End Function
     
    Private Sub Command1_Click()
    Dim lVersion&
          lVersion = getVersion()
        Select Case lVersion
          Case 1
            MsgBox "WIN9X"
          Case 2
            MsgBox "WINNT"
        End Select
    End Sub
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  3. #3

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    Cheers Crispin!

    What would happen if the user has windows 200, will this show up as NT? If so is there any way to tell the difference please?

    Thanks again!

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  4. #4
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    Yeah I just tested it on W2000Pro, it shows up as WINNT - dunno if thats much use or not really, there might be some more info in that OSVERSION struct that could tell you if its NT or W2000...

    hope this helps
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  5. #5

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    No, that's excellent, at least I know cheers.

    I am writing a setup program & will just use the fso.folderexists() to see if the start menu is under the Win2000\documents and settings\, or under NT\winnt\.

    Thanks for your help!

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

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