1、由于需求,settimer在毫秒级别的定时效果精度差,不能满足要求
2、用多媒体定时器
3、使用方法:
- 头文件和库:
#include <MMSystem.h>
#pragma comment(lib,"winmm")
2. 声明响应函数
MMRESULT Timer2;
static void CALLBACK CtimerDlg::timer2proc(
UINT uDelay,
UINT uResolution,
LPTIMECALLBACK lpTimeProc,
DWORD_PTR dwUser,
UINT fuEvent);
3. 设置定时器
Timer2=timeSetEvent(10,1,(LPTIMECALLBACK)timer2proc,(DWORD_PTR)this,TIME_PERIODIC);
4. 定时器响应函数
void CALLBACK CtimerDlg::timer2proc(UINT uDelay,
UINT uResolution,
LPTIMECALLBACK lpTimeProc,
DWORD_PTR dwUser,
UINT fuEvent)
{
PtrC->m_timer2&