timeSetEvent定时器使用

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u013183287/article/details/81976219

 开启定时器:

UINT	m_hTimer;
//PaintCallBack为回调函数
m_hTimer = timeSetEvent(40, 1, PaintCallBack, (DWORD_PTR)this, TIME_PERIODIC);

//PaintCallBack函数实现
VOID CALLBACK PaintCallBack(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2)
{
        
}

关闭时代码:

if (m_hTimer)
{
    timeKillEvent(m_hTimer);
    m_hTimer = NULL;
}

注意:timeSetEvent函数使用时,系统对其有一个不成文的规定,就是同进程创建的定时器不能超过16个,超过16个会创建失败,所以,如果需要N多个定时器的情况,请使用CreateTimerQueueTimer,这个函数也是高精度计时器。

猜你喜欢

转载自blog.csdn.net/u013183287/article/details/81976219