xp系统vba服务器,VBA获取操作系统的版本号(支持windows xp,windows 2003 ,win7 ,win10)

VBA获取操作系统的版本号(支持windows xp,windows 2003 ,win7 ,win10)

Public GetOsVersion() As String

Dim objWMIService, colItems, objItem, strOSversion As String

Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")

For Each objItem In colItems

strOSversion = objItem.Version

Next

Select Case Left(strOSversion, 3)

Case "5.2": strOSversion = "Windows Server 2003"

Case "5.0": strOSversion = "Windows 2000"

Case "5.1": strOSversion = "Windows XP"

Case "6.0": strOSversion = "windows vista"

Case "6.1": strOSversion = "Win7"

Case "6.2": strOSversion = "Win8"

Case "6.3": strOSversion = "Win8.1"

你可能感兴趣的:(xp系统vba服务器)