The timer time set by settimer () is greater than 50 ms, which is not enough in real-time data collection. The multimedia timer can be accurate to 1 ms, and the effect is very good. // Timer # define timer 1int timerid; uint waccuracy; int inittimer (); int releasetimer (); void Pascal timerproc (uint wtimerid, uint MSG, DWORD dwuser, DWORD dwparam, DWORD dlparam); int inittimer () {timecaps TC; If (timegetdevcaps (& TC, sizeof (timecaps) = timerr_noerror) // obtain the value range of the system {waccuracy = min (max (TC. wperiodmin, timer_accuracy), TC. wperiodmax); timebeginperiod (waccuracy); retur N 1;} else {MessageBox (null, "the timer cannot be used! ", Null, null); Return 0 ;}int releasetimer () {timekillevent (timerid); timeendperiod (waccuracy); return 1 ;}/ * Name: timerproc function: timed processing parameters: wtimerid timer ID, MSG message parameters, dwuser, dwparam parameter 1, dlparam parameter 2 */void Pascal timerproc (uint wtimerid, uint MSG, DWORD dwuser, DWORD dwparam, DWORD dlparam) {}// enable the timer timerid = timesetevent (1000, waccuracy, (lptimecallback) timerproc, (DWORD) 0, time_periodic); // 1000 is the scheduled time, indicating 1000 ms