Win32 - read from stdin with timeout

前端 未结 6 1450
时光取名叫无心
时光取名叫无心 2020-12-06 10:11

I\'m trying to do something which I think should be simple: do a blocking read from standard input, but timing out after a specified interval if no data is available.

<
6条回答
  •  孤城傲影
    2020-12-06 11:07

    You'll need the GetStdHandle function to obtain a handle to the console, then you can use WaitForSingleObject to wait for an event to happen on that handle, with a timeout.

提交回复
热议问题