How to Shut Down the System

The Win32 API provides two ways for an application to shut down local or remote computers:

  • Shut down the system.

  • Shut down the system and restart it.

Windows NT: The calling process must have the SE_SHUTDOWN_NAME privilege to shut down the system.

An application can use the ExitWindowsEx function to shut down the system. The system sends the WM_QUERYENDSESSION message to each window, unless ExitWindowsEx is called with the EXW_FORCE flag. While processing WM_QUERYENDSESSION, the applications perform any cleanup and return TRUE to indicate that they can be terminated. If EXW_FORCE is used, applications may lose data. For more information, see Shutting Down.

Windows NT: The InitiateSystemShutdown function starts a timer and displays a dialog box that prompts the user to log off. While the dialog box is displayed, the AbortSystemShutdown function can stop the timer and prevent the computer from shutting down. However, if the timer expires, the computer is shut down. InitiateSystemShutdown can also restart the computer following a shutdown operation. For more information, see Displaying the Shutdown Dialog Box.

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
MegaDetailed.Net
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database