今天项目中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() 函数的作用和用法的更多相关文章

  1. PHP strip_tags() 函数的作用和用法

    strip_tags()函数可以轻松实现从字符串中去除 HTML 和 PHP 标记. 使用方法: trip_tags ( string $str [, string $allowable_tags ] ...

  2. Python __call__内置函数的作用和用法

    开学了进入了实验室,需要协助大师兄做事,主要是OpenStack中的代码解析,但是涉及很多python高级用法,一时间有点麻烦,在做项目的同时慢慢更新博客.这次先写一下__call__的用法,因为经常 ...

  3. Oracle 学习之:ASCII,CHR函数的作用和用法

    对于ASCII以及CHR函数的用法,Oracle给出的解释是: ASCII(x)gets the ASCII value of the character X, CHR() and ASCII() h ...

  4. php中get_headers函数的作用及用法的详细介绍

    get_headers() 是PHP系统级函数,他返回一个包含有服务器响应一个 HTTP 请求所发送的标头的数组.如果失败则返回 FALSE 并发出一条 E_WARNING 级别的错误信息(可用来判断 ...

  5. python中os.path.isdir()等函数的作用和用法

    一 用法和概念: Python中的os模块用于和系统进行交互,其中: 1 os.listdir()用于返回一个由文件名和目录名组成的列表,需要注意的是它接收的参数需要是一个绝对的路径. 2 os.pa ...

  6. getTickCount()函数 VS GetTickCount()函数

    这俩函数看上去长得太像了,笔者曾经马大哈地把两者当成一个函数了(确实长得很像),知道有一天发现返回的值离预期值差很远差仔细查了下. 1. getTickCount() 实际上,该函数为opencv中的 ...

  7. Oracle函数over(),rank()over()作用及用法--分区(分组)求和& 不连续/连续排名

    (1)   函数:  over()的作用及用法:    -- 分区(分组)求和. RANK ( ) OVER ( [query_partition_clause] order_by_clause )D ...

  8. Oracle分析函数及常用函数: over(),rank()over()作用及用法--分区(分组)求和& 不连续/连续排名

    (1)   函数:  over()的作用及用法:    -- 分区(分组)求和. sum() over( partition by column1 order by column2 )主要用来对某个字 ...

  9. rand()和srand()GetTickCount函数用法

    标准库<cstdlib>(被包含于<iostream>中)提供两个帮助生成伪随机数的函数: 函数一:int rand(void):从srand (seed)中指定的seed开始 ...

随机推荐

  1. XSS测试用例与原理讲解

    1.<a href="javascript:alert(32)">DIBRG</a>2.<img href="javascript:aler ...

  2. Mongodb数据更新命令

    一.Mongodb数据更新命令 Mongodb更新有两个命令:update.save. 1.1update命令 update命令格式: db.collection.update(criteria,ob ...

  3. eclipse提交本地项目到github

    1.在https://github.com   new repository 2.在eclipse中new project  比如:Test项目 3.右击"Test"->Te ...

  4. VC自动与Internet时间服务器同步更新

    在VCKBASE.CSDN里挖了许久的坟,才找到一些有点用的资料,最后自己整理出这样的个函数,方面VC实现时间同步,多的不说,自己看源码,根据自己的需要可以适当修改源码: #include <W ...

  5. dump datafile block

    Oracle dump datafile block有两种方式: 然后根据block id执行dump 命令: SQL> alter system dump datafile 4 block 2 ...

  6. 【HDOJ】3436 Queue-jumpers

    离散化+伸展树. /* 3436 */ #include <iostream> #include <string> #include <map> #include ...

  7. USACO3.42American Heritage(二叉树)

    已知中前 求后序 递归一下 有一些小细节 /* ID: shangca2 LANG: C++ TASK: heritage */ #include <iostream> #include& ...

  8. Jersey+Spring+Maven(转)

    spring和maven的搭建参考相关文档.本文只介绍与jersey有关配置. 一.jersey在maven中的依赖包 <!-- jersey --> <dependency> ...

  9. Cocos2d-x 坑之二:目录改动后, cannot run on the selected destination

    1:2dx开发中,目录改动后,经常会碰到这个提示错误:  cannot run on the selected destination 解决方法:一般是因为 Info.plist文件属性问题,把 Ta ...

  10. 基础算法(搜索):NOIP 2015 斗地主

    Description 牛牛最近迷上了一种叫斗地主的扑克游戏.斗地主是一种使用黑桃.红心.梅花.方片的A到K加上大小王的共54张牌来进行的扑克牌游戏.在斗地主中,牌的大小关系根据牌的数码表示如下:3& ...