Postup:
V modulu deklarujte:
Public Const VER_PLATFORM_WIN32s
= 0
Public Const VER_PLATFORM_WIN32_WINDOWS = 1
Public Const VER_PLATFORM_WIN32_NT = 2
'windows typ OSVERSIONINFO
Public Type
OSVERSIONINFO
OSVSize As Long 'velikost
v bitech tΘto struktury
dwVerMajor As Long 'NT
3.51 = 3; NT 4.0 = 4.
dwVerMinor As Long 'NT
3.51 = 51; NT 4.0 = 0.
dwBuildNumber As Long
'NT: build number
OS,Win9x: build number OS v low-order word. High-order word obsahuje major
& minor verze os.
PlatformID
As Long 'Identifikuje
platformu operaΦnφho systΘmu.
szCSDVersion
As String * 128 'NT:
°et∞zec, nap°. "Service Pack 3", Win9x: dalÜφ informace
End Type
'typ pro udr₧enφ zφskan²ch
informacφ
Public Type RGB_WINVER
PlatformID As Long
VersionName As String
VersionNo As String
ServicePack As String
BuildNo As String
End Type
Public Declare Function
GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation
As OSVERSIONINFO) As Long
Public
Function GetWinVersion(WIN As RGB_WINVER) As String
#If
Win32 Then
Dim OSV As OSVERSIONINFO
Dim r As Long
Dim pos As Integer
Dim sVer As String
Dim sBuild As String
OSV.OSVSize = Len(OSV)
If GetVersionEx(OSV) = 1 Then
'PlatformId
obsahuje hodnoty reprezentujφcφ OS
WIN.PlatformID = OSV.PlatformID
Select Case OSV.PlatformID
Case VER_PLATFORM_WIN32s:
WIN.VersionName = "Win32s"
Case VER_PLATFORM_WIN32_WINDOWS:
'dwVerMinor °φkß,
₧e se jednß o W95 nebo W98.
Select Case OSV.dwVerMinor
Case 0: WIN.VersionName = "Windows 95"
Case Else: WIN.VersionName = "Windows 98"
End Select
Case VER_PLATFORM_WIN32_NT:
WIN.VersionName = "Windows NT"
End Select
'ZjiÜt∞nφ Φφsla verze
WIN.VersionNo = OSV.dwVerMajor & "." & OSV.dwVerMinor
'ZjiÜt∞nφ buildu
WIN.BuildNo = (OSV.dwBuildNumber And &HFFFF)
'DalÜφ info. Ve Win9x, to m∙₧e b²t jak²koliv °et∞zec definovan² v²robcem.
'V NT je to Service Pack.
pos = InStr(OSV.szCSDVersion, Chr$(0))
If pos Then
WIN.ServicePack
= Left$(OSV.szCSDVersion, pos - 1)
End If
End If
#Else
'm∙₧e
to b²t pouze nßvratovß hodnota bez podpory 32-bit∙,
'tedy jen Win3x
WIN.VersionName = "Windows 3.x"
#End If
End
Function
Public
Function IsWinNT() As Boolean
#If
Win32 Then
Dim OSV As OSVERSIONINFO
OSV.OSVSize = Len(OSV)
'api vrßtφ 1
pokud bylo volßnφ ·sp∞ÜnΘ
If GetVersionEx(OSV) = 1 Then 'PlatformId
obsahuje hodnoty reprezentujφcφ OS, tak₧e je - li VER_PLATFORM_WIN32_NT,
vrßtφ True
IsWinNT = OSV.PlatformID = VER_PLATFORM_WIN32_NT
End If
#End If
End
Function
Pou₧itφ:
Dim WIN As RGB_WINVER
Call GetWinVersion(WIN)
V typu WIN je pak
pro ka₧dou polo₧ku hodnota.
IsWinNT vracφ bu∩ True nebo False, podle OS
X=IsWinNT()
|