GetTickCount() 函数的作用和用法
今天项目中60秒倒计时模块需要用到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() 函数的作用和用法的更多相关文章
- PHP strip_tags() 函数的作用和用法
strip_tags()函数可以轻松实现从字符串中去除 HTML 和 PHP 标记. 使用方法: trip_tags ( string $str [, string $allowable_tags ] ...
- Python __call__内置函数的作用和用法
开学了进入了实验室,需要协助大师兄做事,主要是OpenStack中的代码解析,但是涉及很多python高级用法,一时间有点麻烦,在做项目的同时慢慢更新博客.这次先写一下__call__的用法,因为经常 ...
- Oracle 学习之:ASCII,CHR函数的作用和用法
对于ASCII以及CHR函数的用法,Oracle给出的解释是: ASCII(x)gets the ASCII value of the character X, CHR() and ASCII() h ...
- php中get_headers函数的作用及用法的详细介绍
get_headers() 是PHP系统级函数,他返回一个包含有服务器响应一个 HTTP 请求所发送的标头的数组.如果失败则返回 FALSE 并发出一条 E_WARNING 级别的错误信息(可用来判断 ...
- python中os.path.isdir()等函数的作用和用法
一 用法和概念: Python中的os模块用于和系统进行交互,其中: 1 os.listdir()用于返回一个由文件名和目录名组成的列表,需要注意的是它接收的参数需要是一个绝对的路径. 2 os.pa ...
- getTickCount()函数 VS GetTickCount()函数
这俩函数看上去长得太像了,笔者曾经马大哈地把两者当成一个函数了(确实长得很像),知道有一天发现返回的值离预期值差很远差仔细查了下. 1. getTickCount() 实际上,该函数为opencv中的 ...
- Oracle函数over(),rank()over()作用及用法--分区(分组)求和& 不连续/连续排名
(1) 函数: over()的作用及用法: -- 分区(分组)求和. RANK ( ) OVER ( [query_partition_clause] order_by_clause )D ...
- Oracle分析函数及常用函数: over(),rank()over()作用及用法--分区(分组)求和& 不连续/连续排名
(1) 函数: over()的作用及用法: -- 分区(分组)求和. sum() over( partition by column1 order by column2 )主要用来对某个字 ...
- rand()和srand()GetTickCount函数用法
标准库<cstdlib>(被包含于<iostream>中)提供两个帮助生成伪随机数的函数: 函数一:int rand(void):从srand (seed)中指定的seed开始 ...
随机推荐
- 记录利用ettercap进行简单的arp欺骗和mitm攻击过程
方法均来自网络,本人只是记录一下自己操作的过程,大神请无视之- 攻击主机平台:kali-linux 被攻击主机:安卓手机192.168.1.107 (在同一局域网内) 1.利用et ...
- WINDOWS下,中文JSON格式读取报错处理:ValueError: No JSON object could be decoded
File "C:\Python27\lib\json\__init__.py", line 290, in load **kw) File "C:\Python27\li ...
- 【UVA 1411】 Ants (KM)
Young naturalist Bill studies ants in school. His ants feed onplant-louses that live on apple trees. ...
- 使用VisualStudio2010创建C#应用程序
打开VisualStudio2010,选择“文件”——“新建”——“项目”菜单命令.调出“新建项目”对话框.
- Linux 安装Maven和nexus代理仓库
1 说明 2 安装步骤 2.1 下载地址 2.2 MAVEN安装步骤 2.2.1 解压Maven安装包 2.2.2 配置环境变量 2.3 Sonatyp ...
- async await 异步编程杂记
1. async 仅仅是用了标记 方法中有异步调用(就是有await...) 2 await 用来把「当前线程」中的代码“分成片”,通过一定条件和事件回调的形式 “依次执行”. 3. await ...
- postMan 使用
Postman功能(https://www.getpostman.com/features) 主要用于模拟网络请求包 快速创建请求 回放.管理请求 快速设置网络代理 安装 下载地址:https://w ...
- SYS_CONTEXT 详细用法
SELECT SYS_CONTEXT ('USERENV', 'TERMINAL') terminal, SYS_CONTEXT ('USERENV', 'LANGUAGE') lang ...
- ImageSwitcher 右向左滑动的实现方式
ImageSwitcher is;...is.setInAnimation(this, android.R.anim.slide_in_left);is.setOutAnimation(this, a ...
- HTML快速入门5——不规则表格、表格背景、边框颜色
转自:http://blog.csdn.net/ysuncn/article/details/2214153 不规则表格 例子: <table border=1><tr>< ...