本文介绍了GetLastInputInfo()始终为0(零)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检测空闲时间(例如,用户按下按键或移动鼠标多长时间).据说GetLastInputInfo()应该是我所需要的,但是当我使用它时,它总是打印0.

I want to detect the idle time (eg. How long ago the user pressed a key or moved the mouse). Supposedly the GetLastInputInfo() should be what I need but, when I use it, it always prints 0.

LASTINPUTINFO   last_input  =   {0};
GetLastInputInfo(&last_input);
cout << last_input.dwTime << endl;

知道为什么吗?

谢谢

使用getlasterror表示参数不正确(ERROR_INVALID_PARAMETER,87)

Using getlasterror, it says that the parameter is incorrect (ERROR_INVALID_PARAMETER,87)

推荐答案

已解决!忘记初始化cbSize了...

Solved! Forgot about initializing cbSize ...

这篇关于GetLastInputInfo()始终为0(零)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-09 02:30