程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> Visual Basic語言 >> VB綜合教程 >> 獲取操作系統版本號

獲取操作系統版本號

編輯:VB綜合教程

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

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved