16.4. Shutting Down the System
It is possible to log the current user off, reboot the system, or shut down the system from within a program. There are many special situations in which these capabilities prove useful. For example, you might want a program to run and then log off the current user when it is done. Then, by locking the screen, one can walk away from the machine and know that it will make itself available to other users upon completion of the program. Listing 16.4 demonstrates how to log off the current user.
Code Listing 16.4. Logging off the system
// silogoff.cpp #include <windows.h> #include <iostream.h> void main() { BOOL success; success = ExitWindowsEx(EWX_LOGOFF, 0); if (success) cout << "Success. Logging off.\n" << endl; ... |
Get Win32 System Services: The Heart of Windows® 98 and Windows® 2000 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.