You didn't mention which operating system you're using. Since this column is from SearchWin2000.com and is about programming for Windows, I'll assume that you're running one of the Microsoft operating systems.
First off you can't trip an interrupt except from a device driver. Fortunately, Microsoft provides several functions that will shut down and restart the computer for you. For Windows 9x/Me, you can use ExitWindowsEx and pass EWX_REBOOT as the ulFlags parameter. For Windows 2000 and above, the user account calling the code will need to have the SE_SHUTDOWN_NAME privilege, so you'll need to call AdjustTokenPrivileges to get the privilege. If you successfully acquire the privilege, you can call InitiateSystemShutdownEx, which gives you more control over how the shutdown and restart will perform than ExitWindowsEx.
This was first published in September 2002
Join the conversationComment
Share
Comments
Results
Contribute to the conversation