(LPTIMECALLBACK) OneMilliSecondProc,//
回调函数
(DWORD)this,//
用户自传送到回调函数的数据
/*周期调用,只使用一次用 TIME_ONESHOT*/
TIME_PERIODIC)) == 0)
{
AfxMessageBox("不能计时", MB_OK | MB_ICONASTERISK);
}
else//不等于 0
表明加装成功,
返回此定时器的句柄
fout < < "16ms 计时:" < < endl;
}
以下为 2
秒定时器的回调函
数和加装函数,与 1
毫秒的类似;
void PASCAL
TwoSecondProc(UINT wTimerID, UINT msg,
DWORD dwUser, DWORD dw1, DWORD dw2)
{
static int s = 0;
CCureApp *app = (CCureApp *)dwUser;
DWORD osBinaryTime = GetTickCount();
app- >fout < < "***********************
***********************" < < endl;
app- >fout < < ++s < < ": 2s : "
< < osBinaryTime < < endl;
}
void CCureApp::StartTwoSecondTimer()
{
if((TimerID_2s = timeSetEvent(wTimerRes_2s, wAccuracy,
(LPTIMECALLBACK) TwoSecondProc,
(DWORD)this,
TIME_PERIODIC)) == 0)
{
AfxMessageBox("不能计时", MB_OK | MB_ICONASTERISK);
}
else
fout < < "2s 计时:" < < endl;
}