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:

  1. add -mwindows command
  2. showwindow(getconsolewindow(), sw_hide);
  3. 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

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -