通过 c++ 运行命令时隐藏控制台窗口
Hide console window while running a command through c++
我使用 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
)
提前感谢您的帮助。
你必须重定向你的输出。有一个成员hStdOutput
和hStdError
应该重定向。MSDN上就是一个例子。
在STARTUPINFO
结构中,在dwFlags
成员中设置 STARTF_USESHOWWINDOW
标志,并将wShowWindow
设置为 SW_HIDE
。
相关文章:
- 在C++中隐藏键盘记录器的控制台窗口
- 如何在 c++ 程序运行时隐藏控制台?
- 如何在调用系统()时隐藏控制台窗口
- ShowCursor(FALSE) 不会在控制台应用程序上隐藏光标
- 如何在使用C++打开隐藏的 COM 对象时隐藏控制台窗口
- 具有隐藏控制台窗口的Allocconsole()
- C++ Windows CreateChildProcess - 隐藏/不显示子进程的控制台窗口
- 对 SDL 隐藏控制台窗口
- Visual C 隐藏控制台窗口
- 如何在QxtApplication中隐藏控制台窗口
- Qt 隐藏控制台窗口停止写入日志文件
- 通过 c++ 运行命令时隐藏控制台窗口
- 当gui程序向cli程序发送命令时,隐藏控制台窗口
- C++ 如何在启动时隐藏控制台窗口
- QProcess::startDetached(),但隐藏控制台窗口
- 在远程进程中隐藏控制台窗口
- 如何在Mac OS中隐藏控制台窗口(gcc编译器)
- 从任务栏隐藏控制台c++程序
- 在程序运行时隐藏控制台的独立于平台的方法
- Qt GUI应用程序与控制台输出-隐藏控制台正常启动上的Windows