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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sysinfo.ocx not

Status
Not open for further replies.

speek

Technical User
Mar 29, 2008
25
US
I need to query if the OS is Win9x or WinNT. I know this can be done with sysinfo.ocx, but can it also be done without sysinfo.ocx? (My VB6 Learning Edition nags about a license when I try to use sysinfo.ocx)
 
You could try using the GetVersionEx API Call.

In a module:

'--------------------------

Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type


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

'--------------

Public sub GetWinVersion()

Dim OSInfo As OSVERSIONINFO, PId As String
Dim Ret As Long

OSInfo.dwOSVersionInfoSize = Len(OSInfo)
Ret = GetVersionEx(OSInfo)

If Ret = 0 Then
MsgBox "Error Getting Version Information"
Else
Select Case OSInfo.dwPlatformId
Case 0
PId = "Windows 32s "
Case 1
PId = "Windows 95/98"
Case 2
PId = "Windows NT "
End Select

MsgBox "OS: " + PId & vbCrLf & "Win version:" + Str$(OSInfo.dwMajorVersion) + "." + LTrim(Str(OSInfo.dwMinorVersion)) & vbCrLf & "Build: " + Str(OSInfo.dwBuildNumber)
End If

End Sub

Good Luck
------------
Select * from Users where Clue > 0
0 rows returned
 
It would be very useful if it worked, but I get a compile error: "User-defined type not defined" on "Dim OSInfo As OSVERSIONINFO"

Speek
 
As indicated from the post, the OSVERSIONINFO is defined at a private type structure type in a module. Therefore, that type would only be know to routines defined within that same module.

The API Function Declaration is also in that same module.

The Sub GetWinVersion must also be in that same module.

Good Luck
------------
Select * from Users where Clue > 0
0 rows returned
 
Thanks, it does work now. But I don't want a message box, but one line of code in Private Sub CommandButton_Click() only when the OS is Windows NT.

The line of code I need is:
sBat = sBat & "echo." & vbCrLf & "pause"
This is to put the command "pause" at the end of a batchfile when the OS is WinNT.

I've tried everything that seemed logical to me, but I'm out of ideas now. Do you have a suggestion?

Speek
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top