国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

【C++程序】[新手向]自動定時關機+限定時間內無法開機工程

2019-11-14 12:52:57
字體:
來源:轉載
供稿:網友

整理代碼片時找到了幾個月以前寫的完整工程,貼出來以供參考。 代碼如下:

#include <string>#include <iostream>#include <fstream>#include <stdlib.h>#include <windows.h>#PRagma comment( linker, "/subsystem:/"windows/" /entry:/"mainCRTStartup/"" ) using namespace std; void CALLBACK TimerProc(HWND hWnd,UINT nMsg,UINT nTimerid,DWord dwTime){ system("erase /q C://time.txt"); system("time /t >> c://time.txt"); char timenow[5]; ifstream infile; infile.open("c://time.txt"); if(infile.is_open()) { for(int i = 0;infile.good() && !infile.eof();i++) { infile >> timenow[i]; } infile.close(); } //將文件中的系統時間寫入數組 char* address[4]; address[0] = &timenow[0]; address[1] = &timenow[1]; address[2] = &timenow[3]; address[3] = &timenow[4]; //獲取小時、分鐘對應地址 int hour = atoi(address[0]); int min = atoi(address[2]); //獲取數字類型的小時、分鐘 if((hour>=24 || hour<07) && (min>=0 && min<=60)) //檢測系統時間是否在對應時間內 { system("shutdown -s"); }}int main(){ system("erase /q C://time.txt"); system("time /t >> c://time.txt"); char timenow[5]; ifstream infile; infile.open("c://time.txt"); if(infile.is_open()) { for(int i = 0;infile.good() && !infile.eof();i++) { infile >> timenow[i]; } infile.close(); } //將文件中的系統時間寫入數組 char* address[4]; address[0] = &timenow[0]; address[1] = &timenow[1]; address[2] = &timenow[3]; address[3] = &timenow[4]; //獲取小時、分鐘對應地址 int hour = atoi(address[0]); int min = atoi(address[2]); //獲取數字類型的小時、分鐘 if((hour>=24 || hour<07) && (min>=0 && min<=60)) //檢測系統時間是否在對應時間內 { system("shutdown -s"); } SetTimer(0,0,60000,&TimerProc); MSG msg; while(GetMessage(&msg,NULL,0,0)) { if(msg.message==WM_TIMER) { DispatchMessage(&msg); } } return 0;}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 婺源县| 莱州市| 合山市| 塔城市| 平南县| 怀远县| 桂平市| 上林县| 安福县| 日喀则市| 滦南县| 闻喜县| 达日县| 新乡市| 富川| 孝感市| 宁夏| 浪卡子县| 盐津县| 呼玛县| 衡南县| 江油市| 师宗县| 镇赉县| 祁阳县| 永康市| 孟连| 云龙县| 廉江市| 兴国县| 灌云县| 双桥区| 龙江县| 南召县| 紫阳县| 武威市| 白银市| 化州市| 延庆县| 云南省| 温泉县|