更新时间:2023-11-28 14:57:46
既然你没有打开那些句柄(那不是GetStdHandle
确实),您不需要关闭它们(也许您想要关闭它们出于其他原因,但不太可能).(注意:即使你做了打开句柄,您不必等待进程退出在关闭它们之前:一旦它们被继承,在父级中关闭它们过程对孩子没有影响).
Since you didn't open those handles (that's not what GetStdHandle
does), you don't need to close them (maybe you want to close them
for some other reason, but it's unlikely). (Note: even if you did
open the handles, you don't have to wait for the process to exit
before you close them: once they are inherited, closing them in parent
process has no effect on the child).
注意 hStdOutput
应该是 INVALID_HANDLE_VALUE
而不是NULL
:这是在 STARTUPINFO
中传递没有句柄的约定.
Note that hStdOutput
should be INVALID_HANDLE_VALUE
instead of
NULL
: that's the convention for passing the absence of a handle in STARTUPINFO
.