gpt4 book ai didi

c++ - 如何以编程方式重启?

转载 作者:可可西里 更新时间:2023-11-01 12:42:18 24 4
gpt4 key购买 nike

如何在 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.

您可以根据自己的情况选择合适的功能。

关于c++ - 如何以编程方式重启?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3697984/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com