龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 软件开发 > VB开发 >

VB 获取操作系统版本号

时间:2009-12-30 15:42来源:未知 作者:admin 点击:
分享到:
Public Declare Function GetVersionExA Lib "kernel32" (lpVersionInformation As OSVERSIONINFO) As Integer Public Type OSVERSIONINFO dwOSVersionInfoSize As Long dwMajorVersion As Long dwMinorVersion As Long dwBuildNumber As Long dwPlatformId A

Public Declare Function GetVersionExA Lib "kernel32" (lpVersionInformation As OSVERSIONINFO) As Integer
Public 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 GetVersion() As String
   Dim osinfo As OSVERSIONINFO
   Dim retvalue As Integer

   osinfo.dwOSVersionInfoSize = 148
   osinfo.szCSDVersion = Space$(128)
   retvalue = GetVersionExA(osinfo)

   With osinfo
    Select Case .dwPlatformId
        Case 1
                Select Case .dwMinorVersion
                    Case 0
                        GetVersion = "Windows 95"
                    Case 10
                        GetVersion = "Windows 98"
                    Case 90
                        GetVersion = "Windows Mellinnium"
                End Select
        Case 2
                Select Case .dwMajorVersion
                    Case 3
                        GetVersion = "Windows NT 3.51"
                    Case 4
                        GetVersion = "Windows NT 4.0"
                    Case 5
                        If .dwMinorVersion = 0 Then
                            GetVersion = "Windows 2000"
                        Else
                            GetVersion = "Windows XP"
                        End If
                End Select
         Case Else
               GetVersion = "Failed"
    End Select
   End With
End Function

精彩图集

赞助商链接