Solved

IsWin95, IsWin98, IsWin2K

Posted on 2000-04-25
7
364 Views
Last Modified: 2008-03-04
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...
0
Comment
Question by:LeXien
7 Comments
 
LVL 20

Expert Comment

by:hes
ID: 2748845
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 2748847
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
 

Expert Comment

by:Cloud_1
ID: 2748923
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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

Expert Comment

by:Cloud_1
ID: 2748957
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
 

Expert Comment

by:Cloud_1
ID: 2749314
Cloud_1 changed the proposed answer to a comment
0
 
LVL 1

Accepted Solution

by:
wolfjjj earned 50 total points
ID: 2750166
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
 

Author Comment

by:LeXien
ID: 2752180
thanks this worked great!

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

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB6 - Convert HH:MM into Decimal 8 54
how to know if my Checkbox is True in VB6.0? 9 53
vbModal 12 51
VBA - If Bookmark = "XXBOOKMARKXX" then 15 23
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now