GetLastInputInfo,GetTickCount与GetTickCount64 [英] GetLastInputInfo, GetTickCount vs GetTickCount64

查看:559
本文介绍了GetLastInputInfo,GetTickCount与GetTickCount64的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用GetLastInput获取当前的空闲时间,但是我对应该检查GetTastCount或GetTickCount64的GetLastInput的返回值感到困惑.返回的值与GetTickCount64匹配,但此调用不适用于pre Vista和GetLastInput中的值只是一个DWORD而不是ULONGLONG(GetTickCount64返回的内容).

重新启动后(不包括48天换行问题),我便得到了值

LASTINPUTINFO信息;
info.cbSize = sizeof(info);
GetLastInputInfo(& info);  
DWORD tickCount64 = GetTickCount64();
DWORD tickCount = GetTickCount();

tickCount64 = 769428
tickCount = 469427
info.dwTime = 763983

GetTickCount似乎总是关闭300001,此值从何而来.这是一台64位的win 7机器.我在其他3台计算机上尝试过,它们在2台计算机上返回相同的值,而在另外1台计算机上返回不同的值.所有人都安装了Visual Studio可以吗 是一个因素吗?

您认为这是怎么回事.

谢谢
scott

解决方案

嗨斯科特,

 

据我所知,经过的时间存储为DWORD值.因此,如果系统连续运行49.7天,该时间将归零.我认为这是GetTickCount的原因 似乎总是300001掉.

来自此文档:

 

最好的问候,

Jesse


I'm trying to get the current idle time using GetLastInput but i'm confused by what i should be checking the return of GetLastInput against, GetTickCount or GetTickCount64.  The value returns matches GetTickCount64 but this call doesn't work on pre vista and the value from GetLastInput is only a DWORD not a ULONGLONG (what GetTickCount64 returns).

Just after a restart (this excludes 48 day wrap issue) i get the values

LASTINPUTINFO info;
info.cbSize = sizeof(info);
GetLastInputInfo(&info);  
DWORD tickCount64 = GetTickCount64();
DWORD tickCount = GetTickCount();

tickCount64 = 769428
tickCount = 469427
info.dwTime = 763983

GetTickCount seems to always be 300001 off, where is this value from.  This is a 64 bit win 7 machine.  I've tried on 3 other machines and they return the same value on 2 and different on 1 other.  All have visual studio installed could this be a factor?

What do you think is going on.

thanks
scott

解决方案

Hi Scott,

 

As far as I know, The elapsed time is stored as a DWORD value. Therefore, the time will wrap around to zero if the system is run continuously for 49.7 days. I think this is reason that GetTickCount seems to always be 300001 off.

From this document:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms724408(v=vs.85).aspx

 

Best regards,

Jesse


这篇关于GetLastInputInfo,GetTickCount与GetTickCount64的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆