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)
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
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?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.