timeSetEvent定时器
2022-06-15
99
0
时间比较准的定时器timeSetEvent。
头文件:
#include <TimeAPI.h>
#pragma comment(lib,"Winmm.lib")
如定时精度为1ms,定时为20ms的定时器。
#define TIME_STEP 20
timeSetEvent(TIME_STEP, 1, (LPTIMECALLBACK)OneMilliSecondProc, // 回调函数;
(DWORD_PTR)this,
TIME_PERIODIC);
回调函数为:
void PASCAL OneMilliSecondProc(UINT wTimerID, UINT msg, DWORD dwUser,
DWORD dwl, DWORD dw2)
{
CVHDMIAppDlg* app = (CVHDMIAppDlg*)dwUser;
app->SendUsbData();
}