Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Explicit
- Private Type OSVERSIONINFO
- dwOSVersionInfoSize As Long
- dwMajorVersion As Long
- dwMinorVersion As Long
- dwBuildNumber As Long
- dwPlatformId As Long
- szCSDVersion As String * 128
- End Type
- Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
- Public Function GetWindowsVersion() As String
- Dim version As String
- Dim os As OSVERSIONINFO 'receives version information
- Dim retval As Long 'return value
- os.dwOSVersionInfoSize = Len(os) 'set the size of the structure
- retval = GetVersionEx(os) 'read Windows's version information
- version = os.dwPlatformId & "." & os.dwMajorVersion & "." & os.dwMinorVersion
- Select Case version
- Case "1.4.0"
- GetWindowsVersion = "Win 95"
- Case "1.4.10"
- GetWindowsVersion = "Win 98"
- Case "1.4.98"
- GetWindowsVersion = "Win ME"
- Case "2.3.51"
- GetWindowsVersion = "Win NT 3"
- Case "2.4.0"
- GetWindowsVersion = "Win NT 4"
- Case "2.5.0"
- GetWindowsVersion = "Win 2000"
- Case "2.5.1"
- GetWindowsVersion = "Win XP"
- Case "2.6.0"
- GetWindowsVersion = "Win Vista"
- Case "2.6.1"
- GetWindowsVersion = "Win Seven"
- Case Else
- GetWindowsVersion = "Unknown"
- End Select
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement