简体   繁体   English

如何使用带最小化主窗口的CreateProcess启动控制台应用程序

[英]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.

相关问题 运行JAR文件的CreateProcess从最小化窗口开始 - CreateProcess for Running JAR File Starts with Window Minimized 如何使用createProcess()启动dx应用 - how to launch dx app using createProcess() 如何显示由createprocess函数隐藏的控制台应用程序窗口 - how to show console app window hidden by createprocess function 在应用程序启动时设置控制台窗口的特定大小 - Setting a console window specific size at application launch 如何从Windows Service主要功能启动C ++本机应用程序(该应用程序与控制台交互)? - How can I launch a C++ native application from a Windows Service main function (the application interacts with the console)? (C ++,Windows)没有控制台窗口的生成子进程(使用CreateProcess) - (C++, Windows) Spawn child process without console window (using CreateProcess) 使用CREATE_NEW_CONSOLE创建流程并保持控制台窗口打开 - CreateProcess with CREATE_NEW_CONSOLE & keep the console window open 如何使用 url 在后台使用应用程序的主 window 启动 UWP 应用程序 - How to launch UWP app with app's main window in background using url 如何使用控制台应用程序中的仅消息窗口接收消息? - How to receive messages using a message-only window in a console application? 如何在没有终端窗口的情况下启动mac应用程序 - How to launch a mac application without a terminal window
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM