Attribute VB_Name = "WinVersion" '=================================================================================================================================================' ' ** ** * ** ** ' ' * * * * ' ' *** *** * ** **** *** ** * *** ** ** *** ** ** **** *** * ** * *** ** ** **** *** *** * ' ' * * ** * * * * * * ** * * ** * * * ** * * ** * * * * * ** * * * * * * * ' ' * * * * * * * * * ***** * * **** * *** * * * * * * * * * * * * * * ' ' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ' ' ** ***** **** *** ***** **** ** **** ****** **** **** ***** ***** ***** *** **** ** **** *** ******* ' ' * * ' ' MMB Developer mmb.developer@gmail.com *** *** ' '=================================================================================================================================================' ' Types for API Calls ' Private Type OSVERSIONINFO dwOSVersionInfoSize As Long dwMajorVersion As Long dwMinorVersion As Long dwBuildNumber As Long dwPlatformId As Long szCSDVersion As String * 128 End Type ' ' Constants ' Public Enum WindowsVersionConstants wvc_Unknown wvc_Win95 wvc_Win98 wvc_WinMe wvc_NT351 wvc_NT4 wvc_2000 wvc_XP wvc_2003 wvc_Vista End Enum ' ' API Calls ' Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" _ (ByRef lpVersionInformation As OSVERSIONINFO) As Long Private Function GetOSVersion() As WindowsVersionConstants ' ' Win95 Win98 WinME NT 3.51 NT 4.0 Win2000 WinXP Win2003 Vista ' ------------------------------------------------------------------------------ 'dwPlatFormID 1 1 1 2 2 2 2 2 2 'dwMajorVersion 4 4 4 3 4 5 5 5 6 'dwMinorVersion 0 10 90 51 0 0 1 2 ' Const VER_PLATFORM_WIN32s = 0 Const VER_PLATFORM_WIN32_WINDOWS = 1 Const VER_PLATFORM_WIN32_NT = 2 Dim tOS As OSVERSIONINFO Dim retval As Long Dim nResult As WindowsVersionConstants tOS.dwOSVersionInfoSize = Len(tOS) retval = GetVersionEx(tOS) With tOS If .dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then Select Case .dwMajorVersion Case 4 Select Case .dwMinorVersion Case 0 nResult = wvc_Win95 Case 10 nResult = wvc_Win98 Case 90 nResult = wvc_WinMe Case Else nResult = wvc_Unknown End Select Case Else nResult = wvc_Unknown End Select ElseIf .dwPlatformId = VER_PLATFORM_WIN32_NT Then Select Case .dwMajorVersion Case 3 nResult = wvc_NT351 Case 4 nResult = wvc_NT4 Case 5 Select Case .dwMinorVersion Case 0 nResult = wvc_2000 Case 1 nResult = wvc_XP Case 2 nResult = wvc_2003 Case Else nResult = wvc_Unknown End Select Case 6 nResult = wvc_Vista Case Else nResult = wvc_Unknown End Select Else nResult = wvc_Unknown End If End With GetOSVersion = nResult End Function Public Function GetWinVersion() As String Select Case GetOSVersion Case wvc_Unknown GetWinVersion = "Unknown Version of Windows" Case wvc_Win95 GetWinVersion = "Windows 95" Case wvc_Win98 GetWinVersion = "Windows 98" Case wvc_WinMe GetWinVersion = "Windows Me" Case wvc_NT351 GetWinVersion = "Windows NT 3.51" Case wvc_NT4 GetWinVersion = "Windows NT 4.0" Case wvc_2000 GetWinVersion = "Windows 2000" Case wvc_XP GetWinVersion = "Windows XP" Case wvc_2003 GetWinVersion = "Windows Server 2003" Case wvc_Vista GetWinVersion = "Windows Vista" End Select End Function