Time-Shutdown Program
All tutorials created in C++ to be posted in here.
1 post
Page 1 of 1
basically just asks you in how many hours, minutes and seconds your computer is supposed to shut down. After declaring the time, a messagebox comes up and asks you to confirm what you have declared.
Code: Select all
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
beginning:;
cout << "Enter time to shutdown"<< endl << "h/min/sec(enter with spaces): ";
int x;
cin >> x;
int y;
cin >> y;
int z;
cin >> z;
char text[255];
sprintf(text, "Shutdown in %d hours, %d minutes and %d seconds. Please confirm.",x, y, z);
int msg;
msg=MessageBox(NULL, text, "Confirmation", MB_OKCANCEL);
switch(msg)
{
case IDOK:
goto timer;
break;
case IDCANCEL:
cout << "Shutdown has been cancelled." << endl;
cout << endl;
goto beginning;
break;
}
timer:;
Sleep(x*3600000 + y*60000 + z*1000);
system("shutdown -s -t 0");
return 0;
}
Back Aegean sorry not been on i.v just been moving.
1 post
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023