Results 1 to 7 of 7

Thread: [RESOLVED] Finding Operating System information

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    10

    Resolved [RESOLVED] Finding Operating System information

    Hi

    I am developeing an application in which i have to run some commands according to the operating system, so application should know on which Operating system it is running.
    like is it running on windows 98 95 , XP or 2000
    so i need a code which should tell me on which OS the application is currently running

    Thanks

  2. #2
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Finding Operating System information

    This is not a deployment question, it's a general VB question.

    Try
    VB Code:
    1. Private Declare Function GetVersion Lib "kernel32" () As Long
    2. Public Function GetWinVersion() As String
    3.     Dim Ver As Long, WinVer As Long
    4.     Ver = GetVersion()
    5.     WinVer = Ver And &HFFFF&
    6.     'retrieve the windows version
    7.     GetWinVersion = Format((WinVer Mod 256) + ((WinVer \ 256) / 100), "Fixed")
    8. End Function
    9. Private Sub Form_Load()
    10.     'KPD-Team 1999
    11.     'URL: [url]http://www.allapi.net/[/url]
    12.     'E-Mail: [email][email protected][/email]
    13.     MsgBox "Windows version: " + GetWinVersion
    14. End Sub

    You can also use GetVersionEx from AllAPI Guide.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    10

    Re: Finding Operating System information

    Thanks for info

    The code you have given tells the versions of windows.
    My question was. I need to know which Operating system?
    That is it should tell me Windows Xp or Windows 98 not the version of the Windows.

  4. #4
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Finding Operating System information

    Well the code posted above does just what you are looking for. It just needs a little more addition. Take a look at this
    VB Code:
    1. 'API Function Which gets the Version Info of OS
    2. Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
    3. Private Type OSVERSIONINFO
    4.     dwOSVersionInfoSize As Long
    5.     dwMajorVersion As Long
    6.     dwMinorVersion As Long
    7.     dwBuildNumber As Long
    8.     dwPlatformId As Long
    9.     szCSDVersion As String * 128
    10. End Type
    11.  
    12.  
    13. 'Function to Get the OS
    14. Public Function GetOSName() As String
    15.     Dim OSV As OSVERSIONINFO
    16.     Dim lReturn As Long
    17.  
    18.     OSV.dwOSVersionInfoSize = Len(OSV)
    19.     lReturn = GetVersionEx(OSV)
    20.    
    21.     If OSV.dwMajorVersion = 4 And OSV.dwMinorVersion = 0 And OSV.dwPlatformId = 1 Then
    22.         GetOSName = "Windows 95"
    23.     ElseIf OSV.dwMajorVersion = 4 And OSV.dwMinorVersion = 10 Then
    24.         GetOSName = "Windows 98"
    25.     ElseIf OSV.dwMajorVersion = 4 And OSV.dwMinorVersion = 90 Then
    26.         GetOSName = "Windows 98 SE"
    27.     ElseIf OSV.dwMajorVersion = 3 And OSV.dwMinorVersion = 51 Then
    28.         GetOSName = "Windows NT 3.51"
    29.     ElseIf OSV.dwMajorVersion = 4 And OSV.dwMinorVersion = 0 And OSV.dwPlatformId = 2 Then
    30.         GetOSName = "Windows ME"
    31.     ElseIf OSV.dwMajorVersion = 5 And OSV.dwMinorVersion = 0 Then
    32.         GetOSName = "Windows 2000"
    33.     ElseIf OSV.dwMajorVersion = 5 And OSV.dwMinorVersion = 1 Then
    34.         GetOSName = "Windows XP"
    35.     End If
    36. End Function
    You can use GetOSName function to get the Operating System Name.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  5. #5

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    10

    Re: Finding Operating System information

    Thanks alot for you help that really helped me

  6. #6
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Finding Operating System information

    You are welcome

    Please mark your thread resolved by select Thread Tools at the top of this thread and select Mark Thread Resolved in the menu.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  7. #7
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: [RESOLVED] Finding Operating System information

    What you no read...

    Quote Originally Posted by randem
    You can also use GetVersionEx from AllAPI Guide.

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