Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" _ (lpVersionInformation As OSVERSIONINFO) As Long
'GetVersionEx Constants
Const VER_PLATFORM_WIN32s = 0
Const VER_PLATFORM_WIN32_Windows = 1
Const VER_PLATFORM_WIN32_NT = 2
Private Sub cGetVersionEx()
Dim V As OSVERSIONINFO, Success&, Junk$, Dummy$
Dim WindowsVersion$, BuildVersion$, SP$, SPL$, PlatformName$
V.dwOSVersionInfoSize = Len(V)
Success = GetVersionEx(V)
WindowsVersion = V.dwMajorVersion & "." & V.dwMinorVersion
BuildVersion = V.dwBuildNumber And &HFFFF&
SP = V.szCSDVersion
Select Case V.dwPlatformId
Case VER_PLATFORM_WIN32_Windows
If V.dwMinorVersion = 0 Then
PlatformName = "Windows 95"
ElseIf V.dwMinorVersion = 10 Then
PlatformName = "Windows 98"
End If
If Trim(SP) = "" Then
MsgBox PlatformName & " Version " & WindowsVersion & ", Build " & BuildVersion, _ vbOKOnly + vbInformation, "Функции API"
Else
MsgBox PlatformName & " Версия " & WindowsVersion & ", Билд " & BuildVersion & ", _ Service Pack " & SP, vbOKOnly + vbInformation
End If
Case VER_PLATFORM_WIN32_NT
PlatformName = "Windows NT"
SPL = Mid(SP, 1, 12)
If SPL = "Service Pack" Then
MsgBox PlatformName & " Версия " & WindowsVersion & ", Билд " & BuildVersion & ", " & _ SP, vbOKOnly + vbInformation
Else
MsgBox PlatformName & " Версия " & WindowsVersion & ", Билд " & BuildVersion, _ vbOKOnly + vbInformation
End If
End Select
End Sub |
|