C++ 延时关闭电脑显示器

180it 2020-10-16 PM 851℃ 0条
#include <windows.h>
#include <iostream>
#include <ctime>
//加入连接库
#pragma comment(lib, "wininet.lib")

using namespace std;
void mySleep(int msecond)
{
    clock_t s;
    s = clock();
    while(clock() - s < msecond);
}

int main(int argc, char* argv[])
{
system("chcp 65001");
system("cls");
cout<<"5秒后关闭显示器"<<endl;
mySleep(5000);
PostMessage(HWND_BROADCAST,WM_SYSCOMMAND,SC_MONITORPOWER,2);
return 0;
}
支付宝打赏支付宝打赏 微信打赏微信打赏

如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!

标签: none

C++ 延时关闭电脑显示器