#include <Windows.h>
VOID WINAPI WaitOrTimerCallBack(PVOID pContext, BOOLEAN bTimeOrWait);
CRITICAL_SECTION g_cs;
int _tmain(int argc, _TCHAR* argv[])
{
wchar_t *pContent = (wchar_t *) malloc(sizeof(wchar_t) * 512);
InitializeCriticalSection(&g_cs);
HANDLE hTimeQueue = CreateTimerQueue();
HANDLE hTimer = NULL;
wsprintfW(pContent, L"Hello Worl");
CreateTimerQueueTimer(&hTimer, hTimeQueue, WaitOrTimerCallBack, pContent,
0, 1000, WT_EXECUTEDEFAULT);
Sleep(5000);
DeleteTimerQueueEx(hTimeQueue, INVALID_HANDLE_VALUE);
DeleteCriticalSection(&g_cs);
wprintf(L"Game over /r/n");
getchar();
free(pContent);
pContent = NULL;
return 0;
}
VOID WINAPI WaitOrTimerCallBack(PVOID pContext, BOOLEAN bTimeOrWait)
{
if (NULL == pContext)
return;
EnterCriticalSection(&g_cs);
wchar_t *pPrintf = (wchar_t *) pContext;
wprintf(L"%s /r/n", pPrintf);
LeaveCriticalSection(&g_cs);
return;
}