c – 如何以编程方式重启?

前端之家收集整理的这篇文章主要介绍了c – 如何以编程方式重启?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何在c中重启? WinSDK有什么规定吗?我的程序(进程)必须这样做什么样的权限?

解决方法

ExitWindowsEx Function可以做到这一点.您需要传递EWX_REBOOT(0x00000002)标志来重新启动系统.

这里的重要提示(从MSDN引用):

The ExitWindowsEx function returns as soon as it has initiated the shutdown process. The shutdown or logoff then proceeds asynchronously. The function is designed to stop all processes in the caller’s logon session. Therefore,if you are not the interactive user,the function can succeed without actually shutting down the computer. If you are not the interactive user,use the InitiateSystemShutdown or InitiateSystemShutdownEx function.

您可以根据您的情况选择适当的功能.

原文链接:https://www.f2er.com/c/114796.html

猜你在找的C&C++相关文章