4

我使用 CreateProcess 运行命令并使用 CREATE_NO_WINDOW 标志,但控制台弹出一小部分时间,如何避免它?

STARTUPINFO si;
PROCESS_INFORMATION pi;

ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );

CreateProcess
( 
NULL,                // No module name (use command line)
command,             //set env variable and use it is my command
NULL,                // Process handle not inheritable
NULL,                // Thread handle not inheritable
FALSE,               // Set handle inheritance to FALSE
CREATE_NO_WINDOW,    //don't create window but it appears for fraction of second!
NULL,                // Use parent's environment block
NULL,                // Use parent's starting directory
&si,                 // Pointer to STARTUPINFO structure
&pi                  // Pointer to PROCESS_INFORMATION structure
)  

提前感谢您的帮助。

4

2 回答 2

0

In your STARTUPINFO structure, set the STARTF_USESHOWWINDOW flag in the dwFlags member, and set wShowWindow to SW_HIDE.

于 2013-09-17T05:45:46.553 回答
0

你必须重定向你的输出。有一个成员hStdOutputhStdError应该重定向。这里在 MSDN 上是一个例子。

于 2013-09-17T06:05:42.350 回答