2004-10-21 04:48:46 +00:00
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
VOID CALLBACK TimerApcProc(
|
|
|
|
LPVOID lpArg,
|
|
|
|
DWORD dwTimerLowValue,
|
2005-05-07 21:24:31 +00:00
|
|
|
DWORD dwTimerHighValue )
|
2004-10-21 04:48:46 +00:00
|
|
|
{
|
|
|
|
printf("APC Callback %lu\n", *(PDWORD)lpArg);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-05-07 21:24:31 +00:00
|
|
|
int main()
|
2004-10-21 04:48:46 +00:00
|
|
|
{
|
|
|
|
HANDLE hTimer;
|
|
|
|
BOOL bSuccess;
|
|
|
|
LARGE_INTEGER DueTime;
|
|
|
|
DWORD value = 1;
|
|
|
|
|
|
|
|
hTimer = CreateWaitableTimer(NULL, FALSE, NULL );
|
2005-05-07 21:24:31 +00:00
|
|
|
|
2004-10-21 04:48:46 +00:00
|
|
|
if (!hTimer)
|
|
|
|
{
|
|
|
|
printf("CreateWaitableTimer failed!\n");
|
|
|
|
return 0;
|
2005-05-07 21:24:31 +00:00
|
|
|
}
|
2004-10-21 04:48:46 +00:00
|
|
|
|
|
|
|
DueTime.QuadPart = -(LONGLONG)(5 * 10000000);
|
|
|
|
|
|
|
|
bSuccess = SetWaitableTimer(
|
|
|
|
hTimer,
|
|
|
|
&DueTime,
|
|
|
|
2001 /*interval (using an odd number to be able to find it easy in kmode) */,
|
|
|
|
TimerApcProc,
|
|
|
|
&value /*callback argument*/,
|
|
|
|
FALSE );
|
|
|
|
|
|
|
|
if (!bSuccess)
|
|
|
|
{
|
|
|
|
printf("SetWaitableTimer failed!\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-05-07 21:24:31 +00:00
|
|
|
for (;value <= 10; value++ )
|
2004-10-21 04:48:46 +00:00
|
|
|
{
|
|
|
|
SleepEx(INFINITE, TRUE /*alertable*/ );
|
|
|
|
}
|
|
|
|
|
|
|
|
CloseHandle( hTimer );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|