如何从使用CreateProcess函数创建的进程重定向输入,输出和错误流?

时间:2013-08-16 11:58:27

标签: c++ c windows process stream

我刚刚学到了一些关于Microsoft CreateProcess函数的内容,但我仍然不知道如何将in-stream,out和err stream重定向到我自己的流。例如,如果我创建这样的过程:

...
comp_exec_args.success = CreateProcess(NULL, comp_exec_args.params, NULL, NULL, comp_exec_args.inherit_handle, 
                                       comp_exec_args.c_flags, NULL, comp_exec_args.root.c_str(), 
                                       &comp_exec_args.startup_info, &comp_exec_args.process_info) ;
...

然后我如何创建类型为std :: istream,std :: ostream和std :: ostream的proc_in,proc_out和proc_err变量,它们将成为进程的进/出/错误流?更确切地说,我可以说我不希望流程流连接到默认的标准输入,输出和错误流,但我想将它们保存在别处。

0 个答案:

没有答案
相关问题