是否有64位等效于GetLastInputInfo/LASTINPUTINFO? [英] Is there a 64 bit equivalent to GetLastInputInfo / LASTINPUTINFO?

查看:63
本文介绍了是否有64位等效于GetLastInputInfo/LASTINPUTINFO?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用 GetLastInputInfo 并从GetTickCount64的结果中计算出差值以确定空闲状态.但是,由GetLastInputInfo返回的滴答计数被写入LASTINPUTINFO的成员dwTime中,该成员dwTime是DWORD,因此是无符号的32位整数,最大值为,最大值为4294967295,相当于〜49天.在正常运行时间更长的机器上,这当然会导致该函数报告错误的值.

We use GetLastInputInfo and calculate the difference from the result of GetTickCount64 to determine idleness. However, the tick count returned by GetLastInputInfo is written into a the member dwTime of LASTINPUTINFO, which is a DWORD and therefore an unsigned 32 bit integer, with a maximum value of and its maximum value of 4294967295, which is equivalent to ~49 days. On machines with uptimes longer than that, this of course leads to the function reporting an incorrect value.

显然没有叫GetLastInputInfo64的函数,但是也许函数的名字不同?

Apparently there is no function called GetLastInputInfo64, but maybe a function under a different name?

推荐答案

我们使用了一种解决方法.

There is a workaround that we use.

仅使用 GetLastInputInfo()的结果来检测 dwTick 是否已更改,而无需关心更改的数量.

Only use the result of GetLastInputInfo() to detect if the dwTick has changed without caring how much it changed.

定期执行此操作.

滴答声发生变化时(该值与上一个读数不同),启动您自己的计时器,并使用该计时器来检测输入何时变为空闲状态(例如30秒).

When the tick has changed (the value is not the same as it was the previous reading) start your own timer and use that to detect when the input has became idle for for instance 30 seconds.

您永远不需要使用这种方法来处理环绕式广告.

You will never need to deal with wraparounds using this approach.

这篇关于是否有64位等效于GetLastInputInfo/LASTINPUTINFO?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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