Q

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.

This was last published in September 2002

Dig Deeper on Microsoft Windows 2000 Server Administration

PRO+

Content

Find more PRO+ content and other member only offers, here.

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.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchServerVirtualization

SearchCloudComputing

SearchExchange

SearchSQLServer

SearchWinIT

SearchEnterpriseDesktop

SearchVirtualDesktop

Close