VBA/Excel/Access/Word/Windows API/OSVERSIONINFO — различия между версиями

Материал из VB Эксперт
Перейти к: навигация, поиск
м (1 версия)
 
м (1 версия)
 
(нет различий)

Текущая версия на 12:48, 26 мая 2010

Declaring the Type Structure OSVERSIONINFO in the General Declarations Section of the Module

 
Type OSVERSIONINFO
   dwOSVersionInfoSize As Long
   dwMajorVersion As Long
   dwMinorVersion As Long
   dwBuildNumber As Long
   dwPlatformId As Long
   strReserved As String * 128
End Type
Declare Function abGetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpOSInfo As OSVERSIONINFO) As Boolean
Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (ByRef lpVersionInformation As OSVERSIONINFO) As Long

Sub GetOSInfo()
    Dim OSInfo As OSVERSIONINFO
    Dim strMajorVersion As String
    Dim strMinorVersion As String
    Dim strBuildNumber As String
    Dim strPlatformId As String
    " Set the length member before you call GetVersionEx
    OSInfo.dwOSVersionInfoSize = Len(OSInfo)
    If GetVersionEx(OSInfo) Then
        strMajorVersion = OSInfo.dwMajorVersion
        strMinorVersion = OSInfo.dwMinorVersion
        strBuildNumber = OSInfo.dwBuildNumber And &HFFFF&
        strPlatformId = OSInfo.dwPlatformId
        Debug.Print "The Major Version Is:  " & strMajorVersion
        Debug.Print "The Minor Version Is:  " & strMinorVersion
        Debug.Print "The Build Number Is:  " & strBuildNumber
        Debug.Print "The Platform ID Is:   " & strPlatformId
    End If
End Sub