Windows API one-day training (69) gettickcount Function

Source: Internet
Author: User
Tags time in milliseconds
Windows API one-day training (69) gettickcount Function

The more accurate the time, the better. Sometimes you only need a time. In this way, you can use the time function gettickcount in milliseconds. This function records the time in milliseconds since the system was started. When it exceeds 49.7 days, the value changes from 0, that is, 49.7 days is a cycle. When two function calls are different, the difference between the two functions is returned.

The gettickcount function declaration is as follows:

Winbaseapi
DWORD
Winapi
Gettickcount (
Void
);

An example of calling a function is as follows:
#001 // General clock time.
#002 // Cai junsheng 2007/11/09 QQ: 9073204 Shenzhen
#003 void testtickcount (void)
#004 {
#005 // obtain the first time value.
#006 DWORD dwstart =: gettickcount ();
#007 for (INT I = 0; I <10; I ++)
#008 {
#009 // calculation interval.
#010 DWORD dwinterval =: gettickcount ()-dwstart;
#011
#012 sleep (100 );
#013
#014 // display interval.
#015 const int nbufsize = 256;
#016 tchar chbuf [nbufsize];
#017 wsprintf (chbuf, _ T ("dwinterval = % d/R/N"), dwinterval );
#018 outputdebugstring (chbuf );
#019}
#020
#021}

Related Article

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.