***************************************************************** * Neveprise Inc. Delphi FAQ * ***************************************************************** * Section: Misc Topic: Exit / reboot Windows * * Created: July 27th, 1999 Revised: July 27th, 1999 * * Updates: www.neveprise.de Info: support@neveprise.de * ***************************************************************** Q: How can I force Windows to shutdown and / or reboot? A: Just call the WinAPI routines ExitWindows() or ExitWindowsEx(): interface type TLogOffModeH( // let us define our own parameters... xwLogOff, //log off current user xwReboot, //shutdown and restart Windows xwShutDown, //just exit Windows xwTurnOff, //shutdown and turn off power (ATX only) xwPanic, //shutsdown, user or other apps cannot interfere xwMSDOX //go to MS-DOS mode ); end; implementation procedure ExitWindowsH(Mode: TLogOffModeH); begin if Mode=xwLOGOFF then ExitWindows(0,0); if Mode=xwREBOOT then ExitWindowsEx(ewx_Reboot,0); if Mode=xwSHUTDOWN then ExitWindowsEx(ewx_Shutdown,0); if Mode=xwTURNOFF then ExitWindowsEx(ewx_PowerOff,0); if Mode=xwPanic then ExitWindowsEx(ewx_Force,0); if Mode=xwMSDOS then //we have to start the PIF, is version dependent!!! ShellExecute(0,'open','C:\Windows\MS-DOS-MODUE.PIF','C:\Windows' ,0,sw_ShowNormal); end; end; Blazko