How I can hide the console during c++ program run-time? -
how can hide console during c++ program run-time?
my compiler : mingw (g++)
i tried lot of things didn't work:
- add
-mwindows
command showwindow(getconsolewindow(), sw_hide);
winmain(...)
code problem here (from comment):
#include <iostream> #include <windows.h> int main() { std::cout << "recompiling compile app..."; system("taskkill /im compile.exe"); system("g++ compile.cpp -o compile.exe"); system("start compile.exe"); return 0; }
how can resolve problem?
seems problem arising calls system
function, runs console window default. if need @ least 1 console window own programm, example you. if don't need output, uncomment line in example.
#include <iostream> #include <windows.h> int main() { // uncomment next line if don't need output @ // freeconsole(); std::cout << "recompiling compile app..."; winexec("taskkill /im compile.exe", sw_hide); winexec("g++ compile.cpp -o compile.exe", sw_hide); winexec("c:\\path\\to\\compile.exe", sw_hide); return 0; }
you can combine old answer achieve desired result.
old answer (still might helpful someone);
this question had been answered here , here already, assuming talking compiling c++
app windows.
basically first answer compile windowed application without window, , second 1 console app hide console window, though flash on screen second or so.
Comments
Post a Comment