Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/156.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ GetLastInputInfo()始终为0(零)_C++_Windows_Winapi - Fatal编程技术网

C++ GetLastInputInfo()始终为0(零)

C++ GetLastInputInfo()始终为0(零),c++,windows,winapi,C++,Windows,Winapi,我想检测空闲时间(例如,用户按键或移动鼠标的时间)。假设GetLastInputInfo()应该是我需要的,但是,当我使用它时,它总是打印0 LASTINPUTINFO last_input = {0}; GetLastInputInfo(&last_input); cout << last_input.dwTime << endl; LASTINPUTINFO last_input={0}; GetLastInputInfo(&last_输入); 无

我想检测空闲时间(例如,用户按键或移动鼠标的时间)。假设GetLastInputInfo()应该是我需要的,但是,当我使用它时,它总是打印0

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

无法解决!忘记初始化cbSize…

尽管滴答数不可靠(如MSDN中所述),但您确定在延迟一段时间后获得滴答数吗?或者只是在启动时调用函数?