Credit Code to crptcblade

VB Code:
  1. Option Explicit
  2.  
  3. Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
  4.  
  5. Private Type OSVERSIONINFO
  6.     dwOSVersionInfoSize As Long
  7.     dwMajorVersion      As Long
  8.     dwMinorVersion      As Long
  9.     dwBuildNumber       As Long
  10.     dwPlatformId        As Long
  11.     szCSDVersion        As String * 128
  12. End Type
  13.  
  14. 'Platform IDs
  15. Private Const WIN_ID_31 = 0
  16. Private Const WIN_ID_95_98_ME = 1
  17. Private Const WIN_ID_NT_2K_XP = 2
  18.  
  19. Public Sub TellWindowsVersion()
  20. Dim lVer As OSVERSIONINFO
  21.    
  22.     lVer.dwOSVersionInfoSize = Len(lVer)
  23.    
  24.     Call GetVersionEx(lVer)
  25.    
  26.     With lVer
  27.         Select Case .dwPlatformId
  28.             Case WIN_ID_31
  29.                 MsgBox "Windows 3.x"
  30.                
  31.             Case WIN_ID_95_98_ME
  32.                 Select Case .dwMinorVersion
  33.                     Case 0:  MsgBox "Windows 95"
  34.                     Case 10: MsgBox "Windows 98"
  35.                     Case 90: MsgBox "Windows Me"
  36.                 End Select
  37.                
  38.             Case WIN_ID_NT_2K_XP
  39.                 Select Case True
  40.                     Case (.dwMajorVersion < 5)
  41.                         MsgBox "Windows NT"
  42.                     Case (.dwMajorVersion = 5)
  43.                         Select Case .dwMinorVersion
  44.                             Case 0: MsgBox "Windows 2000"
  45.                             Case 1: MsgBox "Windows XP"
  46.                         End Select
  47.                 End Select
  48.  
  49.         End Select
  50.     End With
  51.  
  52. End Sub
  53.  
  54. Private Sub Form_Load()
  55.     Call TellWindowsVersion
  56. End Sub