1 ms Timer

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.