Results 1 to 6 of 6

Thread: OS determine

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2004
    Posts
    58

    OS determine

    I am looking through the search to find out how to detemine the OS.

    Basically all I need to do is determine if its win 2000 do something. If win xp do something. I am only going to be installing this program on 2000 or xp only.


    Rob

  2. #2
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    VB Code:
    1. Option Explicit
    2.  
    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 'Maintenance string for PSS usage
    10. End Type
    11.  
    12. Private Declare Function GetVersionEx Lib "kernel32" _
    13.     Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
    14.  
    15. Private Const VER_PLATFORM_WIN32_NT = 2
    16. Private Const VER_PLATFORM_WIN32_WINDOWS = 1
    17.  
    18. Function GetVersion() As String
    19.     Dim os As OSVERSIONINFO
    20.     os.dwOSVersionInfoSize = Len(os)
    21.     GetVersion = "N/A"
    22.     If GetVersionEx(os) Then
    23.         'VER_PLATFORM_WIN32s
    24.         '    Win32s on Windows 3.1.
    25.         'VER_PLATFORM_WIN32_WINDOWS
    26.         '    Windows 95
    27.         '    Windows 98
    28.         '    Windows Me.
    29.         'VER_PLATFORM_WIN32_NT
    30.         '    Windows NT 3.51
    31.         '    Windows NT 4.0
    32.         '    Windows 2000
    33.         '    Windows XP
    34.         '    Windows .NET Server
    35.  
    36.         If os.dwPlatformID = VER_PLATFORM_WIN32_NT Then
    37.             '   Windows NT 3.51 3
    38.             '   Windows NT 4.0 4
    39.             '   Windows 2000 5
    40.             '   Windows XP 5
    41.             '   Windows .NET Server 5
    42.             If os.dwMajorVersion = 3 Then
    43.                 GetVersion = "Microsoft Windows NT 3.51"
    44.             ElseIf os.dwMajorVersion = 4 Then
    45.                 GetVersion = "Microsoft Windows NT 4"
    46.             ElseIf os.dwMajorVersion = 5 Then
    47.                 '   Windows NT 3.51 51
    48.                 '   Windows NT 4.0 0
    49.                 '   Windows 2000 0
    50.                 '   Windows XP 1
    51.                 '   Windows .NET Server 2
    52.                 Select Case os.dwMinorVersion
    53.                     Case 0
    54.                         GetVersion = "Microsoft Windows 2000"
    55.                     Case 1
    56.                         GetVersion = "Microsoft Windows XP"
    57.                     Case 2
    58.                         GetVersion = "Microsoft Windows .NET Server"
    59.                 End Select
    60.             End If
    61.         ElseIf os.dwPlatformID = VER_PLATFORM_WIN32_WINDOWS Then
    62.             '   Windows 95 4
    63.             '   Windows 98 4
    64.             '   Windows Me 4
    65.             GetVersion = "Windows 95/98"
    66.             If os.dwMajorVersion = 4 Then
    67.                 '   Windows 95 0
    68.                 '   Windows 98 10
    69.                 '   Windows Me 90
    70.                 Select Case os.dwMinorVersion
    71.                     Case 0
    72.                         GetVersion = "Microsoft Windows 95"
    73.                     Case 10
    74.                         GetVersion = "Microsoft Windows 98"
    75.                     Case 90
    76.                         GetVersion = "Microsoft Windows Me"
    77.                 End Select
    78.             End If
    79.         End If
    80.     Else
    81.         GetVersion = "N/A"
    82.     End If
    83. End Function
    84.  
    85. Private Sub Form_Load()
    86.     Debug.Print GetVersion
    87. End Sub
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

  3. #3
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959
    VB Code:
    1. Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (ByRef 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

  4. #4

    Thread Starter
    Member
    Join Date
    Jun 2004
    Posts
    58
    I am working on the code will let ui know what happens
    Last edited by PartyInaCan; Aug 10th, 2004 at 10:43 AM.

  5. #5

    Thread Starter
    Member
    Join Date
    Jun 2004
    Posts
    58
    yes this worked fine. My question is did you write this code or did u just figure it out. I am just curious to know.

    Rob

  6. #6
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Originally posted by PartyInaCan
    yes this worked fine. My question is did you write this code or did u just figure it out. I am just curious to know.

    Rob
    I've downloaded it from one or more sites.
    Emiliano F. Martín


    If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
    Encourage the person who helped you to keep doing it, and give him the points he deserves.


    MP3 Organizer: Freeware to logically organize all your MP3s.

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