What Version of Windows?

Many organizations will have different versions of the windows operating system installed on their users’ computers. Occasionally your macros will need to perform different actions based on the version of the Windows operating system on the client computer. The code sample below demonstrates how to determine what version of windows is installed.


Option Explicit

Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" _
(lpVersionInformation As OSVERSIONINFO) As Long

Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type

Public Function Windows_Version() As String
Dim osInfo As OSVERSIONINFO
Dim strTemp As String

osInfo.dwOSVersionInfoSize = Len(osInfo)
GetVersionEx osInfo

Select Case osInfo.dwMajorVersion
Case 4
If osInfo.dwMinorVersion = 0 Then
Windows_Version = "Windows NT"
Else
Windows_Version = "Windows 98"
End If

Case 5
If osInfo.dwMinorVersion = 0 Then
Windows_Version = "Windows 2000"
Else
Windows_Version = "Windows XP"
End If

Case 6
Windows_Version = "Windows Vista"

Case 7
Windows_Version = "Windows 7"

Case Else
Windows_Version = "Unknown"
End Select

End Function

Sub Macro_Display_OS()
Dim strVersion As String

strVersion = Windows_Version

MsgBox "You're operating system is: " & strVersion, vbInformation
End Sub

EnvisionCAD

EnvisionCAD

Since 1996, EnvisionCAD has been a nationally recognized leader in the configuration, customization, implementation, training & support for CAD software solutions. Our individualized approach has benefited private engineering firms and government agencies alike. Basic or advanced, we can help you get the most from your CAD technology.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *