You're on the right track. You can test the console handle before calling ReadConsoleInput:
Code:
if (WaitForSingleObject(hStdin, 5000) == WAIT_OBJECT_0)
{
// Input (keyboard and/or mouse, depending on console mode) is available...
ReadConsoleInput(hStdin,irInBuf,128, &cNumRead);
}
else
{
// WaitForSingleObject returned WAIT_TIMEOUT (or WAIT_FAILED if hStdin is not a valid handle)...
// Handle the timeout...
}
Alternatively, you can use the GetNumberOfConsoleInputEvents function to poll the console for input events.