Disable showing console window

You can disable console by manipulating pre-compiled EXE subsystem- this way you don't need any change in code as you are working on final product- negative aspect is that you would need to do this every time you recompile the project. You can do it via HEX editor or use free CFF Explorer.

  1. Open EXE via CFF Explorer
  2. Go to Nt Headers>Optional Header
  3. Navigate over Subsystem and on the right side click on Windows Console and select Windows GUI.
  4. Save file, console will no longer appear

You can do binary comparison and find the exact location in raw PE header, then maybe do some automation after-compile in VS


You could hide it right on startup. I do not know whether this will cause flicker:

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

In your console application, goto

Properties > Linker > System 

change SubSystem to Windows

and in your code replace

int _tmain(int argc, _TCHAR* argv[])

with

int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)

and add

#include <windows.h>

This should avoid showing a console window in your console application.


In my case (vs2022 c++) all i did was:

Modify

int main() {

to

int WinMain() {

and

Properties > Linker > System change SubSystem to Windows