Контрольная работа: Особливості багатозадачності в середовищі Windows
#include <stdio.h>
#include <conio.h>
#define HOUR (8) // the time of alarm
#define RINGS (10) // number of rings
HANDLE hTerminateEvent;
// callback – timer function
VOID CALLBACK TimerAPCProc(LPVOID, DWORD, DWORD)
{
Beep(1000,500); // ringing!
};
// thread function
unsigned __stdcall ThreadFunc(void *)
{
HANDLE hDayTimer = CreateWaitableTimer(NULL,FALSE,NULL);
HANDLE hAlarmTimer = CreateWaitableTimer(NULL,FALSE,NULL);
HANDLE h[2]; // we will wait for these objects
h[0] = hTerminateEvent; h[1] = hDayTimer;
int iRingCount=0; // number "rings"
int iFlag;
DWORD dw;
// we should convert the time into FILETIME format
// timer don’t understand other formats
LARGE_INTEGER liDueTime, liAllDay;
liDueTime.QuadPart=0;
// day in 100-nanosecond intervals = 10000000 * 60 * 60 * 24 = 0xC92A69C000
liAllDay.QuadPart = 0xC9;
liAllDay.QuadPart=liAllDay.QuadPart << 32;
liAllDay.QuadPart |= 0x2A69C000;
SYSTEMTIME st;