GetTickCount函数为啥总是返回0 ?
时间:2011-12-13
来源:互联网
直接贴代码:
C/C++ code
其中
C/C++ code
已经定义为成员变量,且 m_Time_Start=GetTickCount();已经在oninitialdlg()中初始化,m_Time_End初始化为0;
但是MessageBox()每次弹出0(经常是这个值)或者15、16。
请大家帮忙~
C/C++ code
void CframeDlg::OnBnClickedButtonFrame() { m_Time_Start=GetTickCount(); CDC* pDC=GetDlgItem(IDC_PLAYERXCTRL1)->GetWindowDC(); HDC m_hDC=pDC->GetSafeHdc(); Screen2IplImage(m_hDC,"E://监控录像//xiaowenchao.bmp",m_Width,m_Height); ReleaseDC(pDC); DrawPic2hDC(m_Frame, IDC_STATIC_SHOWIMAGE); for(int i=0;i<10000;i++){} m_Time_End=GetTickCount(); CString time_consumed; m_Time_Consumed=m_Time_End-m_Time_Start; time_consumed.Format("%d",m_Time_Consumed); MessageBox(time_consumed); }
其中
C/C++ code
public: DWORD m_Time_Start; public: DWORD m_Time_End; public: DWORD m_Time_Consumed;
已经定义为成员变量,且 m_Time_Start=GetTickCount();已经在oninitialdlg()中初始化,m_Time_End初始化为0;
但是MessageBox()每次弹出0(经常是这个值)或者15、16。
请大家帮忙~
作者: xiaowenchaojlu 发布时间: 2011-12-13
论坛对此问题解释如下:
What might be happening is that your program runs too fast for it to update, due to its limited resolution.
You can debug the problem by putting a call to Sleep before the second GetTickCount, to see if the difference is now not 0.
补充一下,GetTickCount并不准确,建议改用timeGetTime。
C/C++ code
What might be happening is that your program runs too fast for it to update, due to its limited resolution.
You can debug the problem by putting a call to Sleep before the second GetTickCount, to see if the difference is now not 0.
补充一下,GetTickCount并不准确,建议改用timeGetTime。
C/C++ code
DWORD timeGetTime(void);
作者: fight_in_dl 发布时间: 2011-12-13
m_Time_Start=GetTickCount();
和
m_Time_End=GetTickCount();
之间耗时太少,正常的
加大循环延时就看出效果了
for(int i=0;i<10000000;i++){}
在我机器上 才看出效果来
和
m_Time_End=GetTickCount();
之间耗时太少,正常的
加大循环延时就看出效果了
for(int i=0;i<10000000;i++){}
在我机器上 才看出效果来
作者: gameslq 发布时间: 2011-12-13
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28