<分区>
我的主要功能是带有计时器的经典 Windows 消息循环:
int main()
{
MSG msg;
BOOL bRet;
SetTimer(NULL, 0, 1000, (TIMERPROC) &MainLoop);
while((bRet = GetMessage(&msg, NULL, 0, 0)) != 0)
{
if(bRet == -1)
{
return -1;
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}
这是主循环:
void MainLoop() {
PLASTINPUTINFO plii = NULL;
cout << "in main loop" << endl;
if(GetLastInputInfo(plii) == 0) { exit(-1); };
cout << "in main loop 2" << endl;
}
第二条消息(“在主循环 2 中”)从不显示,但第一条消息每秒显示一次。是否存在 GetLastInputInfo() 不返回的原因?