CSDN近来水气太大,大家都忙于灌水,谁来注意你,你是要用MM_TIMER吧:
#define TARGET_RESOLUTION 1 // 1-millisecond target resolutionTIMECAPS tc;
UINT wTimerRes;if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR)
{
// Error; application can't continue.
}wTimerRes = min(max(tc.wPeriodMin, TARGET_RESOLUTION), tc.wPeriodMax);
timeBeginPeriod(wTimerRes);
//获得,设定时间分辨率
UINT SetTimerCallback(NPSEQ npSeq, // sequencer data
UINT msInterval) // event interval
{
npSeq->wTimerID = timeSetEvent(
msInterval, // delay
wTimerRes, // resolution (global variable)
OneShotCallback, // callback function
(DWORD)npSeq, // user data
TIME_ONESHOT ); // single timer event
if(! npSeq->wTimerID)
return ERR_TIMER;
else
return ERR_NOERROR;
}
//开始计时,设定回调函数
void DestroyTimer(NPSEQ npSeq)
{
if(npSeq->wTimerID) { // is timer event pending?
timeKillEvent(npSeq->wTimerID); // cancel the event
npSeq->wTimerID = 0;
}
}
//释放时钟
大概就这样
#define TARGET_RESOLUTION 1 // 1-millisecond target resolutionTIMECAPS tc;
UINT wTimerRes;if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR)
{
// Error; application can't continue.
}wTimerRes = min(max(tc.wPeriodMin, TARGET_RESOLUTION), tc.wPeriodMax);
timeBeginPeriod(wTimerRes);
//获得,设定时间分辨率
UINT SetTimerCallback(NPSEQ npSeq, // sequencer data
UINT msInterval) // event interval
{
npSeq->wTimerID = timeSetEvent(
msInterval, // delay
wTimerRes, // resolution (global variable)
OneShotCallback, // callback function
(DWORD)npSeq, // user data
TIME_ONESHOT ); // single timer event
if(! npSeq->wTimerID)
return ERR_TIMER;
else
return ERR_NOERROR;
}
//开始计时,设定回调函数
void DestroyTimer(NPSEQ npSeq)
{
if(npSeq->wTimerID) { // is timer event pending?
timeKillEvent(npSeq->wTimerID); // cancel the event
npSeq->wTimerID = 0;
}
}
//释放时钟
大概就这样
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货