7.GetTickCount
原文:
The
GetTickCount function retrieves the number of milliseconds that have elapsed since the system was started. It is limited to the resolution of the system timer. If you need a higher resolution timer, use a
multimedia timer or a
high-resolution timer.
DWORD GetTickCount(VOID)
Parameters
This function has no parameters.
Return Values
The return value is the number of milliseconds that have elapsed since the system was started.
Remarks
The following table describes the resolution of the system timer.
System
|
Resolution
|
Windows NT 3.5 and later
|
The system timer runs at approximately 10ms.
|
Windows NT 3.1
|
The system timer runs at approximately 16ms.
|
Windows 95 and later
|
The system timer runs at approximately 55ms.
|
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.
Windows NT: To obtain the time elapsed since the computer was started, look up the System Up Time counter in the performance data in the registry key
HKEY_PERFORMANCE_DATA. The value returned is an 8-byte value.
QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winbase.h.
Import Library: Use kernel32.lib.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winbase.h.
Import Library: Use kernel32.lib.
See Also
翻译:
GetTickCount函数获得一个以微秒计的数值,它记录了从系统开启到现在所经过的时间。它受系统分辨率的限制,如果需要高分辨率的计时器,使用multimedia timer 或high-resolution timer。
参数:无参数。
返回值:返回值是从系统启动到现在所经过的时间,以微秒计。
备注:下表描述各系统计时器的分辨率:
System
|
Resolution
|
Windows NT 3.5 and later
|
系统计时器分辨率约为10毫秒.
|
Windows NT 3.1
|
系统计时器分辨率约为16毫秒.
|
Windows 95 and later
|
系统计时器分辨率约为55毫秒.
|
经过的时间存储在双字中,49.7天后时间会再次归零。
Window NT:要获得启动后经历的时间,通过查找注册表HKEY_PERFORMANCE_DATA 项的运行数据中System Up Time计数器的一个八字节的值。