Link to home
Start Free TrialLog in
Avatar of LeXien
LeXien

asked on

IsWin95, IsWin98, IsWin2K

Hi,

I need three functions:

ISWin95 - Return true if win95

ISWin98 - return true if win98

ISWin2K - return true if win2k


HOW?

Do i need GetVersionExEx - cause it seems that GetVersionEx cannot tell the difference between win 98 and win95...
Avatar of hes
hes
Flag of United States of America image

i havent tried it with win2000 but it does work to distinguish between 95 and 98:

'GET OS VERSION
'ADD A TEXTBOX TO THE FORM
'***********************************************************************
'
'FORM CODE
'
'***********************************************************************

Private Type MYVERSION
    lMajorVersion As Long
    lMinorVersion As Long
    lExtraInfo As Long
End Type

Private Type OSVERSIONINFO
    dwOSVersionInfoSize As Long
    dwMajorVersion As Long
    dwMinorVersion As Long
    dwBuildNumber As Long
    dwPlatformId As Long
    szCSDVersion As String * 128 ' Maintenance string for PSS usage
End Type
'// Windows Version constants
Private Const VER_PLATFORM_WIN32s = 0
Private Const VER_PLATFORM_WIN32_WINDOWS = 1
Private Const VER_PLATFORM_WIN32_NT = 2
'// Windows Version Declaration
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (ByRef lpVersionInformation As OSVERSIONINFO) As Long
'// Windows Version Function
Private Function WindowsVersion() As MYVERSION
    Dim myOS As OSVERSIONINFO, WinVer As MYVERSION
    Dim lResult As Long

    myOS.dwOSVersionInfoSize = Len(myOS) 'should be 148

    lResult = GetVersionEx(myOS)

    'Fill user type with pertinent info
    WinVer.lMajorVersion = myOS.dwMajorVersion
    WinVer.lMinorVersion = myOS.dwMinorVersion
    WinVer.lExtraInfo = myOS.dwPlatformId

    WindowsVersion = WinVer

End Function


Private Sub Form_Load()
    Dim myVer As MYVERSION
    Dim strTmp As String
    Dim vers As Long
    myVer = WindowsVersion()

    If myVer.lMajorVersion = 4 Then
        If myVer.lExtraInfo = VER_PLATFORM_WIN32_NT Then
            strTmp = "Windows NT version : "
        ElseIf myVer.lExtraInfo = VER_PLATFORM_WIN32_WINDOWS Then
            vers = myVer.lMinorVersion
            If vers <= 10 Then
                strTmp = "Windows 98 version : "
            Else
                strTmp = "Windows 95 version : "
            End If
        End If
    Else
        strTmp = "Windows version : "
    End If

    Text1.Text = strTmp & myVer.lMajorVersion & "." & myVer.lMinorVersion
End Sub



Avatar of Cloud_1
Cloud_1

Just call the API

--------- CUT ----------
Public Type OSVERSIONINFO
  OSVSize         As Long
  dwVerMajor      As Long
  dwVerMinor      As Long
  dwBuildNumber   As Long
  PlatformID      As Long
  szCSDVersion    As String * 128
End Type

Public Declare Function GetVersionEx_ Lib "kernel32" Alias "GetVersionExA"_ (lpVersionInformation As_ OSVERSIONINFO) As Long
--------- CUT ----------

The NT version is held in dwVerMajor/Minor & Win9x version is held in dxBuildNumber.
Pardon the underscores (_) in the line above... I was under the impression I had pasted the line across several line.

(these little post boxes need to be wider) 8-)
Cloud_1 changed the proposed answer to a comment
ASKER CERTIFIED SOLUTION
Avatar of wolfjjj
wolfjjj

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of LeXien

ASKER

thanks this worked great!

Others: i just tried the first one that looked promising and it worked. Sorry :)