如果我创建一个进程和两个管道集,并且该进程在某个时间需要一些用户输入,则GetExitCodeProcess()
从 Windows C API 总是返回1
。作为示例,您可以使用 Windowstime
命令,这将返回:
The current time is: ...
Enter the new time:
然后不等待输入就立即退出。
我不希望该过程在它真正完成之前完成,这样我就可以通过管道输入它。我该如何解决这个问题。
我已经构建了这个循环(我仍然希望能够确定处理何时完成):
for (;;)
{
/* Pipe input and output */
if (GetExitCodeProcess(...) != STILL_ACTIVE) break;
}
提前致谢。
GetExitCodeProcess
不return STILL_ACTIVE
; STILL_ACTIVE
是通过返回的退出代码lpExitCode
输出参数。您需要测试返回的退出代码:
DWORD exitCode = 0;
if (GetExitCodeProcess(handle, &exitCode) == FALSE)
{
// Handle GetExitCodeProcess failure
}
if (exitCode != STILL_ACTIVE)
{
break;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)