VC的CreateProcess创建子进程并创建管道后,子进程的界面SHOW不出来,该如何解决
VC的CreateProcess创建子进程并创建管道后,子进程的界面SHOW不出来
其中代码:
这里如果去掉si.dwFlags |= STARTF_USESTDHANDLES;就能让子进程的界面SHOW出来。
------解决方案--------------------
子进程建立管道后,让他的标准输入输出变为管道
是否在等待管道的输入呢?
------解决方案--------------------
STARTF_USESTDHANDLES Sets the standard input, standard output, and standard error handles for the process to the handles specified in the hStdInput, hStdOutput, and hStdError members of the STARTUPINFO structure.
你前面又是
si.hStdInput = hc2sRead;
si.hStdOutput = hc2sWrite;
其中代码:
- C/C++ code
STARTUPINFO si; memset(&si,0,sizeof(si)); //GetStartupInfo(&si); si.cb = sizeof(si); si.wShowWindow = SW_SHOW; si.hStdInput = hc2sRead; si.hStdOutput = hc2sWrite; si.dwFlags |= STARTF_USESHOWWINDOW; si.dwFlags |= STARTF_USESTDHANDLES;
这里如果去掉si.dwFlags |= STARTF_USESTDHANDLES;就能让子进程的界面SHOW出来。
- C/C++ code
CreateProcess(_T("test.exe"), LPWSTR(strCmd.c_str()), NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi)
------解决方案--------------------
子进程建立管道后,让他的标准输入输出变为管道
是否在等待管道的输入呢?
------解决方案--------------------
STARTF_USESTDHANDLES Sets the standard input, standard output, and standard error handles for the process to the handles specified in the hStdInput, hStdOutput, and hStdError members of the STARTUPINFO structure.
你前面又是
si.hStdInput = hc2sRead;
si.hStdOutput = hc2sWrite;