GetTickCount()函数
GetTickCount(),这个函数,在此做下整理和总结。
1.定义
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.
在Release版本中,该函数从0开始计时,返回自设备启动后的毫秒数(不含系统暂停时间)。
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.
在Debug版本中,设备启动后便从计时器中减去180秒。这样方便测试使用该函数的代码的正确溢出处理。
return values
The number of milliseconds indicates success.
返回值:如正确,返回毫秒数。
2.用法及应用
(1)用来计算系统所用时间,即计算两个时间点的时间间隔
DWORD dwStart = ::GetTickCount();
//执行操作
.......
DWORD dwStop = ::GetTickCount();
DWORD dwInterval = dwStop - dwStart;
(2)用于定时
用于定时器效果,比如用于60秒倒计时:
static int n_gTimeout = 0
n_gTimeout = ::GetTickCount()/1000;
//....执行操作
int nInterval = ::GetTickCount()/1000 - n_gTimeout;
if(nInterval >=60)
{
return;
}
m_nTimeOut = 60 - nInterval;//倒计时时刻
GetTickCount()函数的更多相关文章
- getTickCount()函数 VS GetTickCount()函数
这俩函数看上去长得太像了,笔者曾经马大哈地把两者当成一个函数了(确实长得很像),知道有一天发现返回的值离预期值差很远差仔细查了下. 1. getTickCount() 实际上,该函数为opencv中的 ...
- rand()和srand()GetTickCount函数用法
标准库<cstdlib>(被包含于<iostream>中)提供两个帮助生成伪随机数的函数: 函数一:int rand(void):从srand (seed)中指定的seed开始 ...
- GetTickCount()函数的陷阱!
开发中经经常使用GetTickCount()函数来进行间隔时间的推断.如推断某一段代码运行花了多少时间等,使用比較方便. 可是仅仅针对寻常的一些測试.近期开发一个服务程序时,也在代码中用GetTick ...
- GetTickCount() 函数的作用和用法
今天项目中60秒倒计时模块需要用到GetTickCount(),这个函数,在此做下整理和总结. 1.定义 For Release configurations, this function retur ...
- c、c++---linux上的GetTickCount函数
http://blog.csdn.net/guang11cheng/article/details/6865992 http://wenda.so.com/q/1378766306062794
- 时间的函数,sleep,clock,gettickcount,QueryPerformanceCounter(转)
介绍 我 们在衡量一个函数运行时间,或者判断一个算法的时间效率,或者在程序中我们需要一个定时器,定时执行一个特定的操作,比如在多媒体中,比如在游戏中等,都 会用到时间函数.还比如我们通过记录函数或者算 ...
- opencv —— getTickCount、getTickFrequency 计时函数
getTickCount 函数 返回 CPU 自某个事件(如启动电脑)以来走过的时钟周期数. getTickFrequency 函数 返回 CPU 一秒钟所走过的时钟周期数. 二者结合使用,可以用来计 ...
- 教程-Delphi源代码--后延函数
说明: 1)TTtimer控件 TTtimer控件的实质是调用WindowsAPI定时函数SetTimer和KillTimer来实现的,并简化了对WM_TIMER消息的处理过程.通过设置OnTimer ...
- 一个在字符串中查找多个关键字的函数strstrs(三种不同算法实现及效率分析)
平时项目中有时需要用到在字符串中搜索两个或更多的关键字的情景.例如:将字符串"ab|cd#ef|"按竖线或者井号做分隔 如果是大项目,一般会采用正则表达式做处理.但有时写个小程序, ...
随机推荐
- The equation (扩展欧几里得)题解
There is an equation ax + by + c = 0. Given a,b,c,x1,x2,y1,y2 you must determine, how many integer r ...
- spring boot 多数据源分布式事务处理
有参考文章 ,但是自己没有测试.
- HDU 1043 Eight(双向BFS+康托展开)
http://acm.hdu.edu.cn/showproblem.php?pid=1043 题意:给出一个八数码,求出到达指定状态的路径. 思路:路径寻找问题.在这道题里用到的知识点挺多的.第一次用 ...
- 关于ExtJS Row editing 行编辑 后 获取 编辑后记录值 的方法
listUsersGrid.on('edit', function(editor, e) { var pass = editor.record.data.password; editor.record ...
- Linux——进程管理学习简单笔记
基本概念: 进程和程序的区别 : 1.程序是静态概念,本身作为一种软件资源长期保存:而进程是程序的执行过程,它是动态概念,有一定的生命期,是动态产生和消亡的. 2.程序和进程无一一对应关系.一个程序可 ...
- python datetime模块来获取当前的日期和时间
#!/usr/bin/python # -*- coding: UTF- -*- import datetime i = datetime.datetime.now() print ("当前 ...
- Linux 下的profile
# /etc/profile # System wide environment and startup programs, for login setup# Functions and aliase ...
- The Front-End Checklist
做个记录,摘自Front-End Performance Checklist HTML Minified HTML: The HTML code is minified, comments, whit ...
- C# 通过Newtonsoft.Json.dll序列化日期的处理
Newtonsoft.Json.dll提供了非常好的Json序列化和反序列化方式,但是对日期的处理却让我纠结了很久.首先定义类如下: public class Student{ public int ...
- Lightoj Halloween Costumes
题意:给出要n个时间穿的服装.服装脱下就不能再穿.问最少要准备多少? dp[i][j]表示i到j之间最少花费.如果n=1(n指长度),肯定结果为1,n=2时,也很好算.然后n=3的时候dp[i][j] ...