C++ How do I hide a console window on startup?

后端 未结 9 590
悲哀的现实
悲哀的现实 2021-02-01 05:43

I want to know how to hide a console window when it starts.

It\'s for a keylogger program, but it\'s not my intention to hack someone. It\'s for a littl

9条回答
  •  走了就别回头了
    2021-02-01 05:51

    Hiding a console window at startup is not really possible in your code because the executable is run by the operating system with specific settings. That's why the console window is displayed for a very short time at startup when you use for example FreeConsole(); To really hide the window at startup, you have to add a special option to you compiler. If you use gcc on Windows (MinGW) you can just add -mwindows as compiler option in your makefile and there will be absolutely no window or "flash". I don't know about VisualStudio or whatever you use at the moment, but changing the way your IDE compiles you code is the way to go instead of coding workarounds in C++.

    In my view, this approach is better than using WinMain because it works reliably and you don't make your C++ Code platform dependent.

提交回复
热议问题