[英]How to launch console application using CreateProcess with Minimized main window
I have a native c++ windows application that is launching two child processes using the following code - 我有一个本机c ++ Windows应用程序,它使用以下代码启动两个子进程 -
if (!CreateProcess(NULL, // No module name (use command line)
cmdLine, // szCmdline, // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
false, // Set handle inheritance to FALSE
CREATE_DEFAULT_ERROR_MODE | NORMAL_PRIORITY_CLASS // Process Create Flags
NULL, // Use parent's environment block
NULL, // workingDir, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi) // Pointer to PROCESS_INFORMATION structure
with all parameters in STARTUPINFO block 0. This code works fine in launching the processes. 使用STARTUPINFO块0中的所有参数。此代码在启动进程时工作正常。 However, I need to be able to launch the windows c++ console applications with their windows minimized.
但是,我需要能够在最小化窗口的情况下启动Windows c ++控制台应用程序。
If I add CREATE_NO_WINDOW to the Process Create Flags, I can launch the processes without any windows. 如果我将CREATE_NO_WINDOW添加到Process Create Flags,我可以在没有任何窗口的情况下启动进程。 This will be unacceptable.
这是不可接受的。
In my research, there does not appear to be a way force a console application to open in a minimized mode. 在我的研究中,似乎没有办法强制控制台应用程序以最小化模式打开。 Is this correct?
它是否正确?
Yes, I know that I could minimize the child application windows from within their own process, however, the other programmers on the team prefer not to do this. 是的,我知道我可以在他们自己的进程中最小化子应用程序窗口,但是,团队中的其他程序员不喜欢这样做。
You need to specify in the STARTUPINFO structure that you want your console window to be initially minimized: 您需要在STARTUPINFO结构中指定您希望最初最小化控制台窗口:
ZeroMemory(&si);
si.cb = sizeof(STARTUPINFO);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_MINIMIZE;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.