Platform SDK: Windows System Information
Shutting Down
You can use the ExitWindowsEx function to shut down the system. Shutting down flushes file buffers to disk and brings the system to a condition in which it is safe to turn off the computer.
Windows NT/2000/XP: The following example enables the SE_SHUTDOWN_NAME privilege and then shuts down the system.
HANDLE hToken;
TOKEN_PRIVILEGES tkp;
// Get a token for this process.
if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
error("OpenProcessToken");
Platform SDK: Windows System Information
Shutting Down
You can use the ExitWindowsEx function to shut down the system. Shutting down flushes file buffers to disk and brings the system to a condition in which it is safe to turn off the computer.
Windows NT/2000/XP: The following example enables the SE_SHUTDOWN_NAME privilege and then shuts down the system.
HANDLE hToken;
TOKEN_PRIVILEGES tkp;
// Get a token for this process.
if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
error("OpenProcessToken");