Disable showing console window

后端 未结 4 2069
栀梦
栀梦 2021-02-04 13:27

Where I can disable in Microsoft-Visual-C++ showing console window?

相关标签:
4条回答
  • 2021-02-04 13:39

    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

    0 讨论(0)
  • 2021-02-04 13:44

    Your question is quite ambiguous, so I'm going to try and answer how I interpreted it... If you don't want a console window, try using a different subsystem. Specifically, you probably want the Windows or Native subsystem rather than the Console subsystem.

    0 讨论(0)
  • 2021-02-04 13:46

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

    HWND hWnd = GetConsoleWindow();
    ShowWindow( hWnd, SW_HIDE );
    
    0 讨论(0)
  • 2021-02-04 13:54

    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.

    0 讨论(0)
提交回复
热议问题