Saturday, May 22, 2010

How to shut down or restart pc(windows) using a C program?

only C, not C++





please give me the code for starting %26amp; restarting pc


and tell the libraries to be included

How to shut down or restart pc(windows) using a C program?
You can use -





ExitWindowsEx (EWX_REBOOT, 0);





You might want the optional flag EWX_FORCE. This won't work from a command prompt on 95/98. You need to include windows.h and link with user32.lib for it.





If you don't have user32.lib you need to dynamically link to the function. Ask that as another question. If the user dosen't have the correct privileges this won't work. You need to call another function, ask that as another question.





Note: Microsoft will come around to your house and stand in front of the power button on your PC, because you're not allowed to turn it off. Naughty you. :o)


No comments:

Post a Comment