pTimerThread=AfxBeginThread(TimerThreadFunc,NULL);
isstart=TRUE;
UINT TimerThreadFunc(LPVOID lpParam)
{
HANDLE hTimer = NULL;
LARGE_INTEGER liDueTime;
liDueTime.QuadPart = -100000000L;
// Create an unnamed waitable timer.
hTimer = CreateWaitableTimer(NULL, TRUE, NULL);
if (NULL == hTimer)
{
AfxMessageBox(_T("CreateWaitableTimer failed"));
return 1;
}
// Set a timer to wait for 10 seconds.
if (!SetWaitableTimer(hTimer, &liDueTime, 0, NULL, NULL, 0))
{
AfxMessageBox(_T("SetWaitableTimer failed"));
return 2;
}
// Wait for the timer.
while(WaitForSingleObject(hTimer, INFINITE) == WAIT_OBJECT_0)
{
CTime CurrentTime=CTime::GetCurrentTime();
CString strTime;
strTime.Format("%d:%d:%d",CurrentTime.GetHour(), CurrentTime.GetMinute(),CurrentTime.GetSecond());
AfxMessageBox(strTime);
if (!SetWaitableTimer(hTimer, &liDueTime, 0, NULL, NULL, 0))
{
AfxMessageBox(_T("SetWaitableTimer failed"));
return 2;
}
}
AfxMessageBox("return");
return 0;
}
VOID CALLBACK TimerAPCProc(
LPVOID lpArg, // Data value.
DWORD dwTimerLowValue, // Timer low value.
DWORD dwTimerHighValue ) { // Timer high value.
CTime CurrentTime=CTime::GetCurrentTime();
CString strTime;
strTime.Format("%d:%d:%d",CurrentTime.GetHour(), CurrentTime.GetMinute(),CurrentTime.GetSecond());
AfxMessageBox(strTime);
}