VB 获取操作系统版本 (模块)

前端之家收集整理的这篇文章主要介绍了VB 获取操作系统版本 (模块)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

@H_404_1@Option @H_404_1@Explicit

@H_404_1@Public OSName@H_404_1@As @H_404_1@String'操作系统名称(简称),方便程序控制时根据操作系统取值

@H_404_1@Public Type OSVERSIONINFO
dwOSVersionInfoSize
@H_404_1@As@H_404_1@Long
dwMajorVersion
@H_404_1@As@H_404_1@Long
dwMinorVersion
@H_404_1@As@H_404_1@Long
dwBuildNumber
@H_404_1@As@H_404_1@Long
dwPlatformId
@H_404_1@As@H_404_1@Long
szCSDVersion
@H_404_1@As@H_404_1@String * 128
wServicePackMajor
@H_404_1@As@H_404_1@Integer
wServicePackMinor
@H_404_1@As@H_404_1@Integer
wSuiteMask
@H_404_1@As@H_404_1@Integer
wProductType
@H_404_1@As@H_404_1@Byte
wReserved
@H_404_1@As@H_404_1@Byte
@H_404_1@End Type

@H_404_1@Public @H_404_1@Declare @H_404_1@Function GetVersionEx@H_404_1@Lib "kernel32"@H_404_1@Alias "GetVersionExA" (lpVersionInformation@H_404_1@As OSVERSIONINFO)@H_404_1@As @H_404_1@Long

' 获得 Windows 操作系统的名称,returnType决定返回的方式,值为0时,返回简称,否则返回全称
@H_404_1@Public @H_404_1@Function GetWindowsVersion(@H_404_1@ByVal returnType@H_404_1@As @H_404_1@Integer)@H_404_1@As @H_404_1@String
@H_404_1@Dim ver @H_404_1@As OSVERSIONINFO,retLng@H_404_1@As @H_404_1@Long,os@H_404_1@As @H_404_1@String
ver.dwOSVersionInfoSize
=@H_404_1@Len(ver)
GetVersionEx ver

' retLng = GetVersionEx(ver)
'
If retLng = 0 Then
'
os = "Unknown System Version!"
'
Exit Function
'
End If

@H_404_1@With ver
@H_404_1@Select@H_404_1@Case .dwPlatformId
@H_404_1@Case1
@H_404_1@Select@H_404_1@Case .dwMinorVersion
@H_404_1@Case0
@H_404_1@If returnType= 0@H_404_1@Then
os
="Windows 95"
@H_404_1@Else
@H_404_1@Select@H_404_1@Case .szCSDVersion
@H_404_1@Case"C"
os
="Windows 95 OSR2"
@H_404_1@Case"B"
os
="Windows 95 OSR2"
@H_404_1@Case@H_404_1@Else
os
="Windows 95"
@H_404_1@End@H_404_1@Select
@H_404_1@End@H_404_1@If
@H_404_1@Case10
@H_404_1@If returnType= 0@H_404_1@Then
os
="Windows 98"
@H_404_1@Else
@H_404_1@Select@H_404_1@Case .szCSDVersion
@H_404_1@Case"A"
os
="Windows 98 SE"
@H_404_1@Case@H_404_1@Else
os
="Windows 98"
@H_404_1@End@H_404_1@Select
@H_404_1@End@H_404_1@If
@H_404_1@Case90
@H_404_1@If returnType= 0@H_404_1@Then
os
="Windows Me"
@H_404_1@Else
os
="Windows Millennium Edition"
@H_404_1@End@H_404_1@If
@H_404_1@End@H_404_1@Select
@H_404_1@Case2
@H_404_1@Select@H_404_1@Case .dwMajorVersion
@H_404_1@Case3
os
="Windows NT 3.51"
@H_404_1@Case4
os
="Windows NT 4.0"
@H_404_1@Case5
@H_404_1@Select@H_404_1@Case .dwMinorVersion
@H_404_1@Case0
@H_404_1@If returnType= 0@H_404_1@Then
os
="Windows 2000"
@H_404_1@Else
@H_404_1@Select@H_404_1@Case .wSuiteMask
@H_404_1@Case&H80
os
="Windows 2000 Data center"
@H_404_1@Case&H2
os
="Windows 2000 Advanced"
@H_404_1@Case@H_404_1@Else
os
="Windows 2000"
@H_404_1@End@H_404_1@Select
@H_404_1@End@H_404_1@If
@H_404_1@Case1
@H_404_1@If returnType= 0@H_404_1@Then
os
="Windows XP"
@H_404_1@Else
@H_404_1@Select@H_404_1@Case .wSuiteMask
@H_404_1@Case&H0
os
="Windows XP Professional"
@H_404_1@Case&H200
os
="Windows XP Home"
@H_404_1@Case@H_404_1@Else
os
="Windows XP"
@H_404_1@End@H_404_1@Select
@H_404_1@End@H_404_1@If
@H_404_1@Case2
@H_404_1@If returnType= 0@H_404_1@Then
os
="Windows Server 2003"
@H_404_1@Else
@H_404_1@Select@H_404_1@Case .wSuiteMask
@H_404_1@Case&H2
os
="Windows Server 2003 Enterprise"
@H_404_1@Case&H80
os
="Windows Server 2003 Data center"
@H_404_1@Case&H400
os
="Windows Server 2003 Web Edition"
@H_404_1@Case&H0
os
="Windows Server 2003 Standard"
' Case &H112
'
os = "Windows Server 2003 R2 Enterprise"
@H_404_1@Case @H_404_1@Else
os
="Windows Server 2003"
@H_404_1@End@H_404_1@Select
@H_404_1@End@H_404_1@If
@H_404_1@End@H_404_1@Select
@H_404_1@If returnType<> 0@H_404_1@And .wServicePackMajor> 0@H_404_1@Then
os
= os& " Service Pack" & .wServicePackMajor& @H_404_1@IIf(.wServicePackMinor> 0,"."& .wServicePackMinor,vbNullString)
@H_404_1@End@H_404_1@If
@H_404_1@Case6
@H_404_1@If returnType<> 0@H_404_1@Then
@H_404_1@Select@H_404_1@Case .wProductType
@H_404_1@Case&H6
os
="Business Edition"
@H_404_1@Case&H10
os
="Business Edition (N)"
@H_404_1@Case&H12
os
="Cluster Server Edition"
@H_404_1@Case&H8
os
="Server Datacenter Edition (full installation)"
@H_404_1@Case&HC
os
="Server Datacenter Edition (core installation)"
@H_404_1@Case&H4
os
="Enterprise Edition"
@H_404_1@Case&H1B
os
="Enterprise Edition (N)"
@H_404_1@Case&HA
os
="Server Enterprise Edition (full installation)"
@H_404_1@Case&HE
os
="Server Enterprise Edition (core installation)"
@H_404_1@Case&HF
os
="Server Enterprise Edition for Itanium-based Systems"
@H_404_1@Case&H2
os
="Home Basic Edition"
@H_404_1@Case&H5
os
="Home Basic Edition (N)"
@H_404_1@Case&H3
os
="Home Premium Edition"
@H_404_1@Case&H1A
os
="Home Premium Edition (N)"
@H_404_1@Case&H13
os
="Home Server Edition"
@H_404_1@Case&H18
os
="Server for Small Business Edition"
@H_404_1@Case&H9
os
="Small Business Server"
@H_404_1@Case&H19
os
="Small Business Server Premium Edition"
@H_404_1@Case&H7
os
="Server Standard Edition (full installation)"
@H_404_1@Case&HD
os
="Server Standard Edition (core installation)"
@H_404_1@Case&H8
os
="Starter Edition"
@H_404_1@Case&H17
os
="Storage Server Enterprise Edition"
@H_404_1@Case&H14
os
="Storage Server Express Edition"
@H_404_1@Case&H15
os
="Storage Server Standard Edition"
@H_404_1@Case&H16
os
="Storage Server Workgroup Edition"
@H_404_1@Case&H1
os
="Ultimate Edition"
@H_404_1@Case&H1C
os
="Ultimate Edition (N)"
@H_404_1@Case&H0
os
="An unknown product"
@H_404_1@Case&HABCDABCD
os
="Not activated product"
@H_404_1@Case&H11
os
="Web Server Edition"
@H_404_1@End@H_404_1@Select
@H_404_1@End@H_404_1@If
@H_404_1@Select@H_404_1@Case .dwMinorVersion
@H_404_1@Case0
@H_404_1@Select@H_404_1@Case .wProductType
@H_404_1@Case3
@H_404_1@If returnType= 0@H_404_1@Then
os
="Windows Server 2008"
@H_404_1@Else
os
="Windows Server 2008" & os
@H_404_1@End@H_404_1@If
@H_404_1@Case@H_404_1@Else
@H_404_1@If returnType= 0@H_404_1@Then
os
="Windows Vista"
@H_404_1@Else
os
="Windows Vista " & os
@H_404_1@End@H_404_1@If
@H_404_1@End@H_404_1@Select
@H_404_1@Case1
@H_404_1@Select@H_404_1@Case .wProductType
@H_404_1@Case3
@H_404_1@If returnType= 0@H_404_1@Then
os
="Windows Server 2008 R2"
@H_404_1@Else
os
="Windows Server 2008 R2"& os
@H_404_1@End@H_404_1@If
@H_404_1@Case@H_404_1@Else
@H_404_1@If returnType= 0@H_404_1@Then
os
="Windows 7"
@H_404_1@Else
os
="Windows 7 " & os
@H_404_1@End@H_404_1@If
@H_404_1@End@H_404_1@Select
@H_404_1@End@H_404_1@Select
@H_404_1@If returnType<> 0@H_404_1@And .wServicePackMajor> 0@H_404_1@Then
os
= os& " Service Pack" & .wServicePackMajor& @H_404_1@IIf(.wServicePackMinor> 0,vbNullString)
@H_404_1@End@H_404_1@If
@H_404_1@End@H_404_1@Select
@H_404_1@Case@H_404_1@Else
os
="Unknown System Version!"
@H_404_1@End @H_404_1@Select
@H_404_1@If returnType<> 0@H_404_1@Then os = os &" [Version: " & .dwMajorVersion& "."& .dwMinorVersion& "."& .dwBuildNumber& "]"
@H_404_1@End @H_404_1@With
GetWindowsVersion
= os
@H_404_1@End Function

'返回获取本地连接属性的方式
'
Vista及Win7下 GetDetailsOf(FolderItem,2) 获取的值类似于:“Marvell Yukon 88E8056 PCI-E Gigabit Ethernet Controller”,对应XP、2000及2003下的GetDetailsOf(FolderItem,3)
'
Vista及Win7下 GetDetailsOf(FolderItem,1) 获取的值为本地连接状态,为“网络”时说明正常,对应XP、2000及2003下的GetDetailsOf(FolderItem,2)
@H_404_1@Public @H_404_1@Function getAdapterStatusType()@H_404_1@As @H_404_1@Integer
@H_404_1@Select @H_404_1@Case OSName
@H_404_1@Case "Windows Vista","Windows Server 2008","Windows 7","Windows Server 2008 R2"
getAdapterStatusType
=2
@H_404_1@Case @H_404_1@Else
getAdapterStatusType
=3
@H_404_1@End @H_404_1@Select
@H_404_1@End Function


'返回获取本地连接属性的方式
'
Vista及Win7下 GetDetailsOf(FolderItem,"Windows Server 2008 R2"
getAdapterStatusType
=2
@H_404_1@Case
@H_404_1@Else
getAdapterStatusType
=3
@H_404_1@End @H_404_1@Select
@H_404_1@End Function

猜你在找的VB相关文章