Just paste this code into a new module and change the name of the module to OSVersionInfo.
'----------------------------------------------------------------------
'
' Module Name: OSVersionInfo
' Written By: C&D Programming Corp.
' Create Date: 4/98
' Copyright: Copyright 1998 by C&D Programming Corp. Source
' code may not be reproduced except for use in a
' compiled executable. All rights reserved. If
' you would like to reprint any or all of this
' code please email us at info@codeoftheweek.com
'----------------------------------------------------------------------
Option Explicit
' Declare Type for API call
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long ' Can be used to determine which
' Windows platform we are running on
szCSDVersion As String * 128 ' Will contain Service Pack info under
' Windows NT
End Type
Private Declare Function GetVersionEx Lib "kernel32" _
Alias "GetVersionExA" _
(lpVersionInformation As OSVERSIONINFO) As Long
' Constant declarations for the GetVersionEx function call
Private Const VER_PLATFORM_WIN32_NT = 2
Private Const VER_PLATFORM_WIN32_WINDOWS = 1
Private Const VER_PLATFORM_WIN32s = 0
Public Function IsWin95() As Boolean
Dim osInfo As OSVERSIONINFO
osInfo.dwOSVersionInfoSize = Len(osInfo)
GetVersionEx osInfo
IsWin95 = (osInfo.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS) And _
(osInfo.dwMinorVersion = 0)
End Function
Public Function IsWin98() As Boolean
Dim osInfo As OSVERSIONINFO
osInfo.dwOSVersionInfoSize = Len(osInfo)
GetVersionEx osInfo
IsWin98 = (osInfo.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS) And _
(osInfo.dwMinorVersion = 10)
End Function
Public Function IsWinNT() As Boolean
Dim osInfo As OSVERSIONINFO
osInfo.dwOSVersionInfoSize = Len(osInfo)
GetVersionEx osInfo
IsWinNT = (osInfo.dwPlatformId = VER_PLATFORM_WIN32_NT)
End Function