科学网

 找回密码
  注册

tag 标签: 两种方法

相关帖子

版块 作者 回复/查看 最后发表

没有相关内容

相关日志

VC定时的两种方法
eaglezxw 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
个人分类: 开发经验|2192 次阅读|0 个评论

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

GMT+8, 2024-5-30 19:34

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部