C++ C++;Windows CreateChildProcess-隐藏/不显示子进程';控制台窗口

C++ C++;Windows CreateChildProcess-隐藏/不显示子进程';控制台窗口,c++,windows,process,console,C++,Windows,Process,Console,我需要为我的主进程创建一个子进程作为套接字侦听器/服务器,我使用此调用来实现以下目标: bSuccess = CreateProcessA(NULL, cmdLineArgs, // command line NULL, // process security attributes NULL, // primary thread security attributes

我需要为我的主进程创建一个子进程作为套接字侦听器/服务器,我使用此调用来实现以下目标:

bSuccess = CreateProcessA(NULL, 
            cmdLineArgs,   // command line 
            NULL,          // process security attributes 
            NULL,          // primary thread security attributes 
            TRUE,          // handles are inherited 
            HIGH_PRIORITY_CLASS,             // creation flags 
            NULL,          // use parent's environment 
            NULL,          // use parent's current directory 
            &siStartInfo,  // STARTUPINFO pointer 
            &piProcInfo);  // receives PROCESS_INFORMATION 
有人能说明需要做什么才能使子进程的窗口不显示吗?不希望每次主中央进程创建子进程时都有一个可见的进程窗口

以后编辑我使用了:

HWND hWnd = GetConsoleWindow();
if (hWnd != 0) 
{       
    ShowWindow( hWnd, SW_HIDE);
}
在子进程主函数中,但这并不是最好的解决方案,因为窗口仍会显示几秒钟。如果一个进程有几个子进程,每个子进程都有自己的窗口在屏幕上冒泡,那么它仍然不优雅。是否为编译器设置任何标志以生成“无控制台”输出

我正在使用Visual Studio 2010。

该标志仅用于此目的

您可以将其添加到
dwCreationFlags
位掩码,如下所示:

bSuccess = CreateProcessA(NULL, 
            cmdLineArgs,   // command line 
            NULL,          // process security attributes 
            NULL,          // primary thread security attributes 
            TRUE,          // handles are inherited 
            HIGH_PRIORITY_CLASS | CREATE_NO_WINDOW,  // creation flags 
            NULL,          // use parent's environment 
            NULL,          // use parent's current directory 
            &siStartInfo,  // STARTUPINFO pointer 
            &piProcInfo);  // receives PROCESS_INFORMATION 

必须使用作为
CreateProcess
参数提供的
STARTUPINFO
结构

STARTUPINFO StartInfo= {sizeof(StartInfo)};
StartInfo.dwFlags= STARTF_USESHOWWINDOW;
StartInfo.wShowWindow= SW_HIDE;
应该这样做


再看看

我之所以接受这个答案,是因为它是最快的解决方案(就书面代码而言),但所有其他答案都同样有效+谢谢大家。
siStartInfo.dwFlags &= STARTF_USESHOWWINDOW;
siStartInfo.wShowWindow = SW_HIDE;