如果我为它创build一个进程和两个pipe道集,并且该进程在某个时间需要一些用户input,则Windows C API中的GetExitCodeProcess()
将始终返回1
。 作为一个例子,你可以采取Windows time
命令,这将返回:
The current time is: ... Enter the new time:
然后立即退出而不等待input。
我不希望这个过程完成,直到它真的完成了,所以我可以input它。 我该如何解决这个问题。
我已经build立了这个循环(我仍然希望能够确定何时处理完成):
for (;;) { /* Pipe input and output */ if (GetExitCodeProcess(...) != STILL_ACTIVE) break; }
提前致谢。
GetExitCodeProcess
不返回 STILL_ACTIVE
; STILL_ACTIVE
是通过lpExitCode
out参数返回的退出代码。 您需要测试返回的退出代码:
DWORD exitCode = 0; if (GetExitCodeProcess(handle, &exitCode) == FALSE) { // Handle GetExitCodeProcess failure } if (exitCode != STILL_ACTIVE) { break; }