Search This Blog

Monday, April 11, 2011

Determine Windows version via WIN32 API in VB6

'Get Windows Version
Public Declare Function GetVersionExA Lib "kernel32" _
(lpVersionInformation As OSVERSIONINFO) As Integer

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 Function IsVistaOrHigher() As Boolean
Dim osinfo As OSVERSIONINFO
Dim retvalue As Integer
Dim bVista As Boolean

bVista = False

osinfo.dwOSVersionInfoSize = 148
osinfo.szCSDVersion = Space$(128)
retvalue = GetVersionExA(osinfo)

If osinfo.dwPlatformId = 2 Then
If osinfo.dwMajorVersion = 6 Then
bVista = True
End If
End If
IsVistaOrHigher = bVista
End Function

No comments: