GetVersion (2)




'Constants for determining OS

Private Const VER_PLATFORM_WIN32s = 0
Private Const VER_PLATFORM_WIN32_WINDOWS = 1
Private Const VER_PLATFORM_WIN32_NT = 2
Private Const MAX_PATH = 260
Private Const UNKNOWN_OS = 0
Private Const WINDOWS_NT_3_51 = 1
Private Const WINDOWS_95 = 2
Private Const WINDOWS_NT_4 = 3
Private Const WINDOWS_98 = 4
Private Const WINDOWS_2000 = 5
' UDT for determining OS

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 Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Private Type WIN32_FIND_DATA
dwFileAttributes As Long
ftCreationTime As FILETIME
ftLastAccessTime As FILETIME
ftLastWriteTime As FILETIME
nFileSizeHigh As Long
nFileSizeLow As Long
dwReserved0 As Long
dwReserved1 As Long
cFileName As String * MAX_PATH
cAlternate As String * 14
End Type
Private Declare Function GetVersionEx Lib "kernel32.dll" _
Alias "GetVersionExA" _
(lpVersionInformation As OSVERSIONINFO) As Long
'====================================================

' FUNZIONE

'====================================================

Private Function GetWindowsVersion() As Long
Dim osinfo As OSVERSIONINFO
Dim retvalue As Integer
osinfo.dwOSVersionInfoSize = 148
osinfo.szCSDVersion = Space$(128)
retvalue = GetVersionEx(osinfo)
With osinfo
Select Case .dwPlatformId
Case VER_PLATFORM_WIN32_WINDOWS
If .dwMinorVersion = 0 Then
GetWindowsVersion = WINDOWS_95
ElseIf .dwMinorVersion = 10 Then
GetWindowsVersion = WINDOWS_98
End If
Case VER_PLATFORM_WIN32_NT
If .dwMajorVersion = 3 Then
GetWindowsVersion = WINDOWS_NT_3_51
ElseIf .dwMajorVersion = 4 Then
GetWindowsVersion = WINDOWS_NT_4
ElseIf .dwMajorVersion = 5 Then
GetWindowsVersion = WINDOWS_2000
End If
Case Else
GetWindowsVersion = UNKNOWN_OS
End Select
End With
End Function











( getversion2.html )- by Paolo Puglisi - Modifica del 17/12/2023