Контрольная работа: Особливості багатозадачності в середовищі Windows
iFlag = st.wHour > HOUR; // if the Time don’t come
// than we set alarm for today, if not than for tomorrow
st.wHour = HOUR;
st.wMinute = 0;
st.wSecond =0;
FILETIME ft;
SystemTimeToFileTime(&st, &ft);
if (iFlag)
((LARGE_INTEGER *)&ft)->QuadPart =
((LARGE_INTEGER *)&ft)->QuadPart +liAllDay.QuadPart;
LocalFileTimeToFileTime(&ft,&ft);
// Installing the timer,
// it will alarm once a day
SetWaitableTimer(hDayTimer, (LARGE_INTEGER *) &ft, 24*60*60000, 0, 0, 0);
do {
dw = WaitForMultipleObjectsEx(2,h,FALSE,INFINITE,TRUE);
if (dw == WAIT_OBJECT_0 +1) // hDayTimer
{
SetWaitableTimer(hAlarmTimer, &liDueTime, 1000, TimerAPCProc, NULL, 0);
iRingCount=0;
}
if (dw == WAIT_IO_COMPLETION) // the callback-functionhas finished working
{
iRingCount++;
if (iRingCount==RINGS)
CancelWaitableTimer(hAlarmTimer);
}
}while (dw!= WAIT_OBJECT_0); // while hTerminateEvent is of
CancelWaitableTimer(hDayTimer);