只要呼叫GetOS_Version就能傳回OS版本
傳回資料型態為String
複製程式碼(copy to clipboard)
Option Explicit
Public Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
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 OS_Version As OSVERSIONINFO
Public Function GetOS_Version() As String
OS_Version.dwOSVersionInfoSize = Len(OS_Version)
GetVersionEx OS_Version
If OS_Version.dwPlatformId = 2 Then
GetOS_Version = "Windows" & " " & OS_Version.dwMajorVersion & "." & OS_Version.dwMinorVersion
ElseIf OS_Version.dwPlatformId = 1 Then
If OS_Version.dwMinorVersion = 90 Then
GetOS_Version = "Windows Me"
ElseIf OS_Version.dwMinorVersion = 10 Then
GetOS_Version = "Windows 98"
ElseIf OS_Version.dwMinorVersion = 0 Then
GetOS_Version = "Windows 95"
Else
GetOS_Version = "Error"
End If
Else
GetOS_Version = "Error"
End If
End Function
沒有留言:
張貼留言