关机代码

· · 个人记录

#include<bits/stdc++.h>
#include<windows.h>
using namespace std;

int main(){
    cout<<"关机程序\n"; 
    if(MessageBox(NULL,"是否运行?","它将关掉你的电脑!",MB_YESNO|MB_ICONEXCLAMATION)==IDYES){
        system("shutdowm -s -t 30");
        cout<<"30秒后关机!"; 
    }
    else{
        cout<<"运行失败......"; 
    }
    return 0;
}