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...
LeXienAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
wolfjjjConnect With a Mentor Commented:
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 GetVersion() As Integer
  Dim osinfo As OSVERSIONINFO
  Dim retvalue As Integer
 
  osinfo.dwOSVersionInfoSize = 148
  osinfo.szCSDVersion = Space$(128)
  retvalue = GetVersionExA(osinfo)
 
  With osinfo
    Select Case .dwPlatformId
      Case 1
        If .dwMinorVersion = 0 Then
          GetVersion = 1 'win95
        ElseIf .dwMinorVersion = 10 Then
          GetVersion = 2 'win98
        End If
      Case 2
        If .dwMajorVersion = 3 Then
          GetVersion = 3 'win nt 3.51
        ElseIf .dwMajorVersion = 4 Then
          GetVersion = 4 'win nt 4
        ElseIf .dwMajorVersion = 5 Then
          GetVersion = 5 'win2000
        End If
      Case Else
        GetVersion = 0 'unknown os
    End Select
  End With
End Function

---------
pretty straight forward,
0 == unknown OS
1 == win95
2 == win98
3 == winNT 3.51
4 == winNT 4
5 == win2K

hope this helps

0
 
AzraSoundCommented:
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



0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Cloud_1Commented:
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.
0
 
Cloud_1Commented:
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-)
0
 
Cloud_1Commented:
Cloud_1 changed the proposed answer to a comment
0
 
LeXienAuthor Commented:
thanks this worked great!

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

From novice to tech pro — start learning today.