1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
#include "pch.h"
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <istream>
#include <windows.h>
#include <stdio.h>
#include <conio.h>
HANDLE hEvent = NULL;
VOID CALLBACK TimerAPCProc(
LPVOID lpArgToCompletionRoutine,
DWORD dwTimerLowValue,
DWORD dwTimerHighValue
)
{
printf("In TimerAPCProc\n");
SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED);
if (IsSystemResumeAutomatic())
{
printf("IsSystemResumeAutomatic :: True\n");
}
else {
printf("IsSystemResumeAutomatic :: False\n");
}
SetEvent(hEvent);
}
int main()
{
HANDLE hTimer = NULL;
LARGE_INTEGER liDueTime;
liDueTime.QuadPart = 20 * -10000000LL; // 20 seconds
hEvent = CreateEvent(NULL, FALSE, FALSE, TEXT("TimerEvent"));
// Create an unnamed waitable timer.
hTimer = CreateWaitableTimer(NULL, FALSE, NULL);
if (NULL == hTimer)
{
printf("CreateWaitableTimer failed (%d)\n", GetLastError());
return 1;
}
printf("Waiting for 20 seconds...\n");
// Set a timer to wait for ... seconds.
if (!SetWaitableTimer(hTimer, &liDueTime, 0, TimerAPCProc, NULL, TRUE))
{
printf("SetWaitableTimer failed (%d)\n", GetLastError());
return 2;
}
if (ERROR_NOT_SUPPORTED == GetLastError())
{
printf("System restore is not supported \n");
}
// Wait for the timer.
SleepEx(INFINITE, TRUE);
printf("Timer was signaled.\n");
if (WaitForSingleObject(hEvent, INFINITE) != WAIT_OBJECT_0)
printf("TimerAPCProc failed (%d)\n", GetLastError());
else printf("TimerAPCProc was signaled.\n");
// Calls the random video selecting batch file
system("C:\\Users\\danny\\Desktop\\video.bat");
return 0;
}
|