函数GetTickcount和DWORD关键字
来源:互联网 发布:李东峰 北京航天数据 编辑:程序博客网 时间:2024/06/05 04:26
GetTickcount函数:它返回从操作系统启动到当前所经过的毫秒数,常常用来判断某个方法执行的时间,其函数原型是DWORD GetTickCount(void),返回值以32位的双字类型DWORD存储,因此可以存储的最大值是(2^32-1) ms约为49.71天,因此若系统运行时间超过49.71天时,这个数就会归0,MSDN中也明确的提到了:"Retrieves the number of milliseconds that have elapsed since the system was started, up to 49.7 days."。因此,如果是编写服务器端程序,此处一定要万分注意,避免引起意外的状况(如需避免此种情况可使用Ctime类或者是系统API的SYSTEMTIME进行判断)。
特别注意:这个函数并非实时发送,而是由系统每18ms发送一次,因此其最小精度为18ms。当需要有小于18ms的精度计算时,应使用StopWatch方法进行。
INT 代表int,
DWORD 代表 unsigned long
int会随着机器位数的不同而发生变化,比如在16位机上为16为,在32位机上为32位,在64位机上为64位。
DWORD是无符号的,相当于unsigned long ,它是MFC的数据类型。
而int是有符号性的,而且他所占的字节数不一定是4个,主要和你的
IDE有关,像在Turbo C中就是2个字节,VC6.0中就是4个字节
切忌把 int 看成 32 位
书中早就说了
long 32位有符号整数int 32位有符号整数DWORD 32位无符号整数typedef unsigned long DWORD;DWORD 一般用于返回值不会有负数的情况。到底是用 int 还是 DWORD,要看具体情况。
0 0
- 函数GetTickcount和DWORD关键字
- DWORD 关键字
- SetTimer函数和GetTickCount()函数的用法
- SetTimer函数和GetTickCount()函数的用法
- GetTickCount函数
- GetTickCount函数
- GetTickCount函数
- GetTickCount函数
- GetTickcount函数
- GetTickCount函数
- 【总结】GetTickCount() 函数的作用和用法
- GetTickCount() 函数的作用和用法!
- rand()和srand()GetTickCount函数用法
- GetTickCount() 函数的作用和用法
- GetTickCount() 函数的作用和用法
- GetTickCount()函数的作用和用法
- rand()和srand()GetTickCount函数用法
- GetTickCount函数---GetTickCount返回(retrieve)从操作系统启动到现在所经过(elapsed)的毫秒数,它的返回值是DWORD。
- a configuration error occurred during startup.Please verify the preference field with the prompt:Can
- uva 343 What Base Is This?
- 1069
- 11.可阻塞的队列
- BZOJ P1177[Apio2009]Oil
- 函数GetTickcount和DWORD关键字
- 1070
- poj 3259
- mybatis 插入数据库中文乱码
- 1071
- 解决Android Studio不能进入调试模式问题
- 4.2(数组)课程管理
- leetcode441. Arranging Coins
- 1072