Is there a function to just restart Windows, and not the whole computer?
Printable View
Is there a function to just restart Windows, and not the whole computer?
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.
here is some code that i wrote in VB, you got to convert it into C/C++/VC++ :)
regards,VB Code:
'// 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
LOL :) I don't think the user would be too fond of that.Quote:
Originally posted by Matthew Gates
You could just crash explorer and this would force Windows to refresh/restart itself.
Wynd, you could use the ExitWindowsEx() function.
Code:ExitWindowsEx(EWX_FORCE | EWX_REBOOT, 0);
Just to restart Windows use:
Code:ExitWindowsEx(EWX_LOGOFF, 0);
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.
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.
One way is to hold shift while restarting. I don't know if you can programmatically simulate this though.
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