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}
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/li_guotao/archive/2009/01/09/3741380.aspx