GetTickCount
来源:互联网 发布:网络歌曲2015 编辑:程序博客网 时间:2024/05/22 09:46
GetTickCount记录了从系统启动时经过的时间,精确到毫秒。
For Release configurations, this function returns the number of milliseconds since the device booted, excluding any time that the system was suspended. GetTickCount starts at 0 on boot and then counts up from there.
For Debug configurations, 180 seconds is subtracted from the the number of milliseconds since the device booted. This allows code that uses GetTickCount to be easily tested for correct overflow handling.
Syntax
DWORD GetTickCount(void);
Return Value
The number of milliseconds indicates success.
Remarks
The resolution of the system timer is based on the OEM's setting. Check with the OEM for details.
The elapsed time is stored as a DWORD value. Therefore, the time will rollover to zero if the system is run continuously for 49.7 days.
For Debug configurations, 180 seconds is subtracted to check for overflow conditions in code that relies on GetTickCount. If this code started within 3 minutes of the device booting, it will experience an overflow condition if it runs for a certain amount of time.
Note:
When using GetTickCount, subtraction is safe, even if the rollover occurred, and subtraction always yields the correct difference and the number of clock ticks passed between two tick values. Comparing tick values directly does not always yield the correct results; only compare the differences. Be sure that your code can service the difference before the second rollover, that is, before another 49.7 days pass. Comparisons such as the following are not safe.
#define DELTA_TICKS sample_tick_value// initialized somewhere in the codeDWORD dwStartTick = GetTickCount();DWORD dwEndTick = GetTickCount() + DELTA_TICKS;// The following function fails on a rollover.BOOL no_compare_tick_difference(){ if ( GetTickCount() > dwEndTick ) return ( TRUE); return (FALSE);}
The following code shows how to properly use GetTickCount by comparing tick differences. This code handles the rollover situation.
BOOL compare_tick_difference(){ if ( (GetTickCount() – dwStartTick) > DELTA_TICKS) return ( TRUE); return (FALSE);}
You can use the GetTickCount function to time the duration of an activity as shown in the example below.
dwOldTime = GetTickCount();DoSomething();dwTimeElapsed = GetTickCount() – dwOldTime;
On the STMicro platform, the time returned by GetTickCount includes a ~0.014% time drift, which is by design. This translates to a time lag of approximately 1 second every 2 hours.
Requirements
OS Versions: Windows CE 1.0 and later.
Header: Winbase.h.
Link Library: Coredll.lib.
- GetTickCount
- GetTickCount
- GetTickCount
- 7.GetTickCount
- GetTickCount函數
- GetTickCount() 用法
- GetTickCount函数
- GetTickCount函数
- GetTickCount函数
- GetTickCount函数
- GetTickcount函数
- GetTickCount函数
- GetTickCount()和GetCurrentTime()
- GetTickCount的实现
- GetTickCount使用的注意事项
- C++ GetTickCount函数
- VC GetTickCount ()函数
- getpeername(),getsockname(),listen(),gettickcount()
- Spanky - beloved ~桜の彼方へ~ -full ver
- 内网抓包数据的还原组报问题,谁能解决,一定重谢.
- perl学习小结(5):句柄操作,打开,关闭
- erlang开发中的简单进程框架(非OTP)
- “将数据发送到运行IIS的计算机的请求失败.有关详细信息请参阅HRESULT”解决方法
- GetTickCount
- 三种 bottom half的实现方式 softirqs, tasklets, work queue 及之间的比较
- VGT200 工业级双模亚米级无线车载GPS定位终端
- 笑一笑,十年少
- HPUX常用核心参数配置说明
- 如何在ECLIPSE中自动添加注释
- MDT3500 工业级可对讲智能车载GPS对讲机电脑
- 对web.config的数据库连接字符串进行加密
- 中国软件公司如何扬长避短小公司大赚钱