大佬教程收集整理的这篇文章主要介绍了Windows在运行长C Visual Studio程序时会休眠,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我知道这是因为在运行程序(调试)时超出了睡眠等待时间,我可以通过增加睡眠等待时间或在Windows控制面板电源设置中将设置设置为“从不”来轻松停止.
以这个例子为例….
#include <cstdlib> //include windows.h using namespace std; void KeepMonitOractive() { // Enable away mode and prevent the sleep idle time-out. SetThreadEXECUTIONState(ES_CONTinUOUS | ES_SYstem_required | ES_AWAymODE_required); } void RestoreMonitorSetTings() { // Clear EXECUTION_STATE flags to disable away mode and allow the system to idle to sleep normally. SetThreadEXECUTIONState(ES_CONTinUOUS); } int main() { //Add these 2 lines at the entry point in your program KeepMonitOractive(); atexit(RestoreMonitorSetTings); //... }
以上是大佬教程为你收集整理的Windows在运行长C Visual Studio程序时会休眠全部内容,希望文章能够帮你解决Windows在运行长C Visual Studio程序时会休眠所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。