Problem solve Get help with specific problems with your technologies, process and projects.

Using C, what is the interrupt I can use to make a computer shut down and restart?

I would like to know the interrupt with which a computer can be made to shut down and restart. I am using C language to develop the application.
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.

Dig Deeper on Legacy operating systems

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.