GetTickCount function
Retrieves the number of milliseconds that have elapsed since the system was started, up to 49.7 days.
Syntax
DWORD WINAPI GetTickCount(void);
Parameters
This function has no parameters.
Return value
The return value is the number of milliseconds that have elapsed since the system was started.
Remarks
The resolution of the GetTickCount function is limited to the resolution of the system timer, which is typically in the range of 10 milliseconds to 16 milliseconds. The resolution of the GetTickCount function is not affected by adjustments made by the GetSystemTimeAdjustment function.
The elapsed time is stored as a DWORD value. Therefore, the time will wrap around to zero if the system is run continuously for 49.7 days. To avoid this problem, use the GetTickCount64 function. Otherwise, check for an overflow condition when comparing times.
If you need a higher resolution timer, use a multimedia timer or a high-resolution timer.
To obtain the time elapsed since the computer was started, retrieve the System Up Time counter in the performance data in the registry key HKEY_PERFORMANCE_DATA. The value returned is an 8-byte value. For more information, see Performance Counters.
To obtain the time the system has spent in the working state since it was started, use the QueryUnbiasedInterruptTime function.
Requirements
|
Minimum supported client | Windows 2000 Professional |
|---|---|
|
Minimum supported server | Windows 2000 Server |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
Send comments about this topic to Microsoft
Build date: 9/7/2011
- 8/1/2011
- rogerdpack2
"The resolution of the GetTickCount function is not affected by adjustments made by the GetSystemTimeAdjustment function."
The GetSystemTimeAdjustment does not adjust the time to counter for lag (either explicitly if provided by the programmer) or through synchronizing to some external source.
Also the Set/GetSystemTimeAdjustment does not change the resolution it only adjust for the drift.
Does the GetTickcount lags behind the systemtime (which is adjusted either every interval if SetSystemTimeAdjustment is enabled or by the system periodically which cause the jumps in the system time reported after the system adjusting the time with some external source)? If it does, does this mean the GetTickcount just adds the system time interrupt interval to this counter (on every clock interrupt). (e.g gettickcount is not adjusted for lag and will lag behind the system time delta taken from boot time)
Thanks.
[DllImport("kernel32.dll", CharSet=CharSet.Auto, ExactSpelling=true)]
public static extern int GetTickCount();
- 4/26/2009
- dmex
