鹰击长空,拼搏吧!!! 态度决定成败!分享 http://blog.sciencenet.cn/u/eaglezxw 邹兴文,工学硕士,甘肃漳县人,计算机视觉入门者,算法工程师

博文

VC定时的两种方法

已有 2169 次阅读 2010-4-1 09:28 |个人分类:开发经验|系统分类:科研笔记|关键词:学者| 定时, 两种方法

1、可以采用GetTickCount()函数,该函数的返回值是DWORD型,表示以毫秒为单位的计算机启动后经历的时间间隔。 ? ? DWORD ? dwStart ? = ? GetTickCount(); ? ? DWORD ? dwEnd ? = ? dwStart; ? ? do ? ? { ? ? ? ? ? ? ? MSG ? ? msg; ? ? ? ? ? ? ? GetMessage(&msg,NULL,0,0); ? ? ? ? ? ? ? TranslateMessage(&msg); ? ? ? ? ? ? DispatchMessage(&msg); ? ? ? ? ? ? dwEnd ? = ? GetTickCount(); ? ? ? ? } ? while((dwEnd ? - ? dwStart) ? ? <= ? ? 2000); ? ? ? ? 2、? 一种更精确的微秒级延时: ? ? LARGE_INTEGER ? ? litmp ? ; ? ? LONGLONG ? ? QPart1,QPart2 ? ; ? ? double ? d=0; ? ? QueryPerformanceCounter(&litmp) ? ; ? ? ? // ? 获得初始值 ? ? QPart1 ? = ? litmp.QuadPart ? ; ? ? while ? (d<40)//你想要的时间 ? ? { ? ? ? ? ? ? QueryPerformanceCounter(&litmp) ? ; ? ? ? ? ? ? ? QPart2 ? = ? litmp.QuadPart ? ; ? ? ? ? ? ? d=(double)(QPart2 ? - ? QPart1); ? ? } ? From:http://topic.csdn.net/t/20050528/23/4042951.html

https://m.sciencenet.cn/blog-379528-307879.html

上一篇:MFC设置透明对话框
下一篇:VC定时及计时的三种方法

0

发表评论 评论 (0 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-5-9 06:02

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部