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

Windows 98 - Windows 2000

Status
Not open for further replies.

Danielvb

Programmer
Oct 8, 2002
34
US
Hello everyone

Plaease I need your help. I have a small application that runs in Windows 98 and windows 2000. I found this code that help me to ReStart the PC. For windows 98 works but windows 2000.

'===========
'CODE HERE: |
'===========
Const EWX_LOGOFF = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long

Private Sub Form_Load()
Let msg = MsgBox("THIS PROGRAM IS GOING TO REBOOT YOUR COMPUTER. PRESS [OK] TO CONTINUE...", vbCritical + vbOKOnly + 256, App.TITLE)
If (msg = vbOK) Then End
ret& = ExitWindowsEx(EWX_FORCE Or EWX_REBOOT, 0)
Exit Sub
End Sub




===========
QUESTIONS |
===========
I would like to acomplish the following task.
1- Detect the operating system (Windows 98 / windows 2000
2- Depending on the Operating system Restart the PC

Can somebody help me out in order to acomplish this task

Thanks in advance for your time

Danielvb
Hollywood, Florida




 
The SysInfo control has an OSPlatform property. It gives 0 for Win32s, 1 for 95/98 and 2 for NT, W2K and XP


________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
one way to get OS version is as follows:-

further info at:-

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

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

Public Sub GetVersionInfo()

Dim lret As Long
Dim osverinfo As OSVERSIONINFO
osverinfo.dwOSVersionInfoSize = Len(osverinfo)
lret = GetVersionEx(osverinfo)
If lret = 0 Then
' raiseAPIError lret
Else
Debug.Print "version: " & osverinfo.dwMajorVersion & "." _
& osverinfo.dwMinorVersion
Debug.Print "Build: " & osverinfo.dwBuildNumber
Debug.Print "Platform ID: " & osverinfo.dwPlatformId
Debug.Print "String: " & osverinfo.szCSDVersion
End If

Select Case osverinfo.dwPlatformId & "/" & osverinfo.dwMajorVersion & _
"/" & osverinfo.dwMinorVersion

Case "1/4/0"
OS = "Win95"
Case "1/4/10"
OS = "Win98"
Case "2/3/51"
OS = "WinNT 3.51"
Case "2/4/0"
OS = "WinNT 4.0"
'there are more cases you can find these at
Case Else
OS = "Unknown"

End Select

Debug.Print "Platform: " & OS

End Sub

as for exitwindowex, hmmm i think MSDN will explain the ups and downs of this call better, see:-


good luck!

If somethings hard to do, its not worth doing - Homer Simpson
------------------------------------------------------------------------
A General Guide To Excel in VB FAQ222-3383
File Formats Galore @
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top