#define _WIN32_WINNT 0x0501
#include <windows.h>
#include <iostream>
usingnamespace std;
int main ()
{
int actionType;
int seconds;
cout << "What would you like to do?" << endl;
cout << "1 = shutdown; 2 = hibernate" << endl;
cin >> actionType;
if (actionType != 1 || actionType != 2)
{
cout << "Invalid action ID" << endl;
cout << "Please retype action ID" << endl;
cin >> actionType;
}
cout << "Seconds until action: ";
cin >> seconds;
if ((MessageBox(NULL, "Are you sure?", "Confirm", MB_OKCANCEL)) == MB_OK)
{
HWND hWnd = GetConsoleWindow();
ShowWindow(hWnd, SW_HIDE);
Sleep(seconds * 1000);
if (actionType == 1)
{
system("shutdown -s -f -t 10");
}
elseif (actionType == 2)
{
system("rundll32.exe powrprof.dll,SetSuspendState 0,1,0");
}
}
return 0;
}
When I compile it it doesn't shout at me but when I run it it always displays the "Invalid action ID" the first time I enter either 1 or 2 and then works up until the