如:在模块 mGrid 中
[code]
' System detection
Private Declare Function GetVersion Lib "kernel32" () As Long
' Private variables
Private m_bIsXp As Boolean
Private m_bIsNt As Boolean
Private m_bInit As Boolean
''' <summary>
''' 返回当前系统是否为 Windows XP 以上版本.
''' </summary>
''' <returns><c>True</c> if the system is running XP or above.</returns>
Public Property Get isXp() As Boolean
If Not (m_bInit) Then
VerInitialise
End If
isXp = m_bIsXp
End Property
Public Property Get IsNt() As Boolean
If Not (m_bInit) Then
VerInitialise
End If
IsNt = m_bIsNt
End Property
''' <summary>
''' 获取 Windows 版本并设置 m_bIsXp
''' </summary>
Private Sub VerInitialise()
Dim lMajor As Long
Dim lMinor As Long
GetWindowsVersion lMajor, lMinor
If (lMajor > 5) Then
m_bIsXp = True
ElseIf (lMajor = 5) And (lMinor >= 1) Then
m_bIsXp = True
End If
m_bInit = True
End Sub
''' <summary>
''' 返回当前运行的 Windows 版本
''' </summary>
''' <param name="lMajor">
''' Windows 主版本号
''' </param>
''' <param name="lMinor">
''' Windows 次版本号
''' </param>
''' <param name="lRevision">
''' Windows 修订号
''' </param>
''' <param name="lBuildNumber">
''' Windows 版本号
''' </param>
Private Sub GetWindowsVersion( _
Optional ByRef lMajor = 0, _
Optional ByRef lMinor = 0, _
Optional ByRef lRevision = 0, _
Optional ByRef lBuildNumber = 0 _
)
Dim lR As Long
lR = GetVersion()
lBuildNumber = (lR And &H7F000000) \ &H1000000
If (lR And &H80000000) Then lBuildNumber = lBuildNumber Or &H80
lRevision = (lR And &HFF0000) \ &H10000
lMinor = (lR And &HFF00&) \ &H100
lMajor = (lR And &HFF)
m_bIsNt = ((lR And &H80000000) = 0)
End Sub
[/code]