开发者

prevent command line from opening on _popen

开发者 https://www.devze.com 2023-04-08 22:37 出处:网络
I\'m opening a process in C++ like so FILE* pipe = _popen(ss.str().c_str(), \"r\"); This create a cmd window which goes to the forefront of the desktop. I want to prevent the cmd window from openin

I'm opening a process in C++ like so

FILE* pipe = _popen(ss.str().c_str(), "r");

This create a cmd window which goes to the forefront of the desktop. I want to prevent the cmd window from opening, and if I can't, a way to keep it minimized.

Tried solutions:

HWND hWnd = GetConsoleWindow();
ShowWindow(hWnd, SW_HIDE);

But that only wor开发者_StackOverflow社区ks if you are calling that function in the process that holds the cmd window.


Instead of using _popen, use CreateProcess and the CREATE_NO_WINDOW flag.

0

精彩评论

暂无评论...
验证码 换一张
取 消