GetTickCount64
Retrieves the number of milliseconds that have elapsed since the system was started.
Syntax
ULONGLONG GetTickCount64();
Parameters
This function does not take any parameters.
Return Value
The return value is the number of milliseconds that have elapsed since the system was started. This value is a 64-bit integer.
Remarks
The value returned by GetTickCount64 is a time value.
It is not a wall-clock time. The value wraps around approximately every 292 years.
For this reason, you should not compare the return values of this function
across different system startups. Instead, if you need to measure elapsed time,
you should call GetTickCount64 once at the beginning of the interval
and then again at the end, and subtract the first value from the second.
This function is suitable for measuring short intervals of time.
For more accurate time measurements, consider using high-resolution performance counters.
The QueryPerformanceCounter function provides a higher-resolution timer.
Note
The GetTickCount function is a 32-bit version of this function.
GetTickCount64 is recommended for new applications because it
avoids the rollover problem of GetTickCount which occurs every 49.7 days.
Example
The following example demonstrates how to use GetTickCount64 to measure elapsed time.
#include <windows.h>
#include <iostream>
int main() {
ULONGLONG startTime = GetTickCount64();
// Simulate some work
Sleep(2000); // Sleep for 2 seconds
ULONGLONG endTime = GetTickCount64();
ULONGLONG elapsedTime = endTime - startTime;
std::cout << "Elapsed time: " << elapsedTime << " milliseconds." << std::endl;
return 0;
}
Requirements
| Item | Value |
|---|---|
| Minimum supported client | Windows Vista [desktop apps | UWP apps] |
| Minimum supported server | Windows Server 2008 [desktop apps | UWP apps] |
| Target Platform | Windows |
| Header | Winbase.h (include Windows.h) |
| Library | Kernel32.lib |
| DLL | Kernel32.dll |