PDA

Click to See Complete Forum and Search --> : Restart Windows?


Wynd
Aug 6th, 2001, 01:30 PM
Is there a function to just restart Windows, and not the whole computer?

Matthew Gates
Aug 6th, 2001, 05:56 PM
You could just crash explorer and this would force Windows to refresh/restart itself. I believe you can do this with the TerminateProcess API function.

Chris
Aug 7th, 2001, 05:40 AM
here is some code that i wrote in VB, you got to convert it into C/C++/VC++ :)


'// Main Form
Private Sub cmdAction_Click()
If optShutdown(0).Value Then
Exit_Wnd 0
ElseIf optShutdown(1).Value Then
Exit_Wnd 1
ElseIf optShutdown(2).Value Then
Exit_Wnd 2
ElseIf optShutdown(3).Value Then
Exit_Wnd 3
End If
End Sub

'// Basic Module
Option Explicit
'// WIN32API Function
Public Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long

'// WIN32API Constant
Const EWX_LOGOFF = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4

Public Sub Exit_Wnd(ByVal lpChoice As Integer)
Select Case lpChoice
Case 0
'Logoff
ExitWindowsEx EWX_FORCE Or EWX_LOGOFF, 0
Case 1
'ShutDown
ExitWindowsEx EWX_FORCE Or EWX_SHUTDOWN, 0
Case 2
'Reboot
ExitWindowsEx EWX_FORCE Or EWX_REBOOT, 0
Case 3
'???
ExitWindowsEx EWX_FORCE Or EWX_FORCE, 0
End Select
End Sub

regards,

Megatron
Aug 7th, 2001, 06:11 AM
Originally posted by Matthew Gates
You could just crash explorer and this would force Windows to refresh/restart itself.
LOL :) I don't think the user would be too fond of that.


Wynd, you could use the ExitWindowsEx() function.

ExitWindowsEx(EWX_FORCE | EWX_REBOOT, 0);

wey97
Aug 11th, 2001, 01:36 AM
Just to restart Windows use:

ExitWindowsEx(EWX_LOGOFF, 0);

Wynd
Aug 11th, 2001, 09:21 AM
Ok, thanks guys. The reason I asked is because lots of programs I've seen say "You must restart Windows to complete the installation" or something, but they restart the computer, not Windows.

Sastraxi
Aug 12th, 2001, 06:43 AM
But you don't have to necessarily restart the computer, a lot of the newer programs caught on to this, go into DOS for a few seconds, and come right back in.

Megatron
Aug 12th, 2001, 07:43 AM
One way is to hold shift while restarting. I don't know if you can programmatically simulate this though.

hazgul
Aug 13th, 2001, 03:10 AM
Microsoft disabled the shift thingy in Windows ME and Win2K because some motherboards don't restart HDDs and FDDs right when you do it. It's better to restrt the wole computer :D