Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i detect which operating system is running 3

Status
Not open for further replies.

inncoggnitto

Programmer
Jun 19, 2001
77
US
i have an app that can't do some functions when installed on win95 because the third party active x/dlls wont't install on the machine (i know, but i work at a state agency and only just getting around to rolling out win2k on some of the 3k plus machines). i need to disable/make invisible some buttons on the 95s, so i need to tell if that is the os.

i know it must be simple but not having luck w/my references.

thanks
 
You might want to take a look at the GetVersionEx API call Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
I also use API function for this.

But you may want to try using the
Microsoft SysInfo Control 6.0
under PROJECT|COMPONENTS
The MS help files also give examples. [/b][/i][/u]*******************************************************[sub]
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
looked up GetVersionEx in the msdn library and it appears to be part of the platform sdk. i need it to work in vb6
 
the Microsoft SysInfo Control 6.0
works pretty easily.

not sure how to use api calls but i did a simple test as suggested above. works well enough. thanks

Code:
Private Sub Command1_Click()
   Dim MsgEnd As String
   If SysInfo1.OSPlatform = 1 Then
         MsgEnd = "Windows 95, ver. " & CStr(SysInfo1.OSVersion)
   Else
        MsgEnd = "Windows NT, ver. " & CStr(SysInfo1.OSVersion)
   End If
   MsgBox "System: " & MsgEnd
End Sub
 
For the api use this:


Public Const VER_Processor_WIN32_NT& = 2
Public Const VER_Processor_WIN32_WINDOWS& = 1

Public Type OSVersionInfo
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwProcessorID As Long
szCSDVersion As String * 128
End Type

Global myVer As OSVersionInfo

Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVersionInfo) As Long

Public Function VersionInformation() As String
Dim txtOperatingSystem As String
Dim txtVersion As String
Dim txtBuildNumber As String
Dim txtServicePack As String

Dim flagnum&
Dim dl&, s$
Dim vernum&, verword%

myVer.dwOSVersionInfoSize = 148
dl& = GetVersionEx&(myVer)

If myVer.dwProcessorID = VER_Processor_WIN32_WINDOWS Then
txtOperatingSystem = "Windows95"
ElseIf myVer.dwProcessorID = VER_Processor_WIN32_NT Then
txtOperatingSystem = "Windows NT"
End If

txtVersion = myVer.dwMajorVersion & "." & myVer.dwMinorVersion
txtBuildNumber = (myVer.dwBuildNumber And &HFFFF&)
txtServicePack = myVer.szCSDVersion

VersionInformation = txtOperatingSystem & vbCrLf & txtVersion & vbCrLf & txtBuildNumber & vbCrLf & txtServicePack

End Function
 
[poke] Here's what I use:

'********************
'* OS VERSION
'********************
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 Declare Function GetVersionExA Lib "kernel32" _
(lpVersionInformation As OSVERSIONINFO) As Integer

Public Function GetWindowsVersion() As String
' Purpose: Find Windows version

On Error GoTo ErrHandler
Dim strOSName As String
Dim OSInfo As OSVERSIONINFO

OSInfo.dwOSVersionInfoSize = 148
OSInfo.szCSDVersion = Space$(128)

' API call to get operating system info.
Call GetVersionExA(OSInfo)

With OSInfo
Select Case .dwPlatformId
Case 1
Select Case .dwMinorVersion
Case 0
strOSName = "Windows 95"
Case 10
strOSName = "Windows 98"
Case 90
strOSName = "Windows Millennium"
End Select
Case 2
Select Case .dwMajorVersion
Case 3
strOSName = "Windows NT 3.51"
Case 4
strOSName = "Windows NT 4.0"
Case 5
If .dwMinorVersion = 0 Then
strOSName = "Windows 2000"
Else
strOSName = "Windows XP"
End If
End Select
Case Else
strOSName = "Failed"
End Select
End With

GetWindowsVersion = strOSName

ExitHere:
Exit Function
ErrHandler:
Call LogError("Module: modSystem", "GetWindowsVersion( )", Err, Err.Description)
Resume ExitHere
End Function VBSlammer
redinvader3walking.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top