新建一个form1窗体,复制过去即可运行:
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
osName As String
End Type
Private Function GetWindowsVersion() As OSVERSIONINFO
Dim ver As OSVERSIONINFO
ver.dwOSVersionInfoSize = 148
GetVersionEx ver
With ver
Select Case .dwPlatformId
Case 1
Select Case .dwMinorVersion
Case 0
.osName = "Windows 95"
Case 10
.osName = "Windows 98"
Case 90
.osName = "Windows Mellinnium"
End Select
Case 2
Select Case .dwMajorVersion
Case 3
.osName = "Windows NT 3.51"
Case 4
.osName = "Windows NT 4.0"
Case 5
If .dwMinorVersion = 0 Then
.osName = "Windows 2000"
Else
.osName = "Windows XP"
End If
End Select
Case Else
.osName = "Failed"
End Select
End With
GetWindowsVersion = ver
End Function
Private Sub Form_Load()
Me.AutoRedraw = True
Me.ForeColor = vbRed
Me.FontSize = 25
Dim ver As OSVERSIONINFO
ver = GetWindowsVersion()
With ver
Me.Print "操作系统 :" & .osName & vbCrLf & _
"版本 :" & .dwMajorVersion & "." & .dwMinorVersion & vbCrLf & _
"Build :" & .dwBuildNumber & vbCrLf & _
"? :" & .dwPlatformId & vbCrLf & _
"Service Pack:" & .szCSDVersion
End With
End Sub
如下图所示的效果:
联系客服