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

后端 未结 9 593
悲哀的现实
悲哀的现实 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:57

    It is simple. FreeConsole() api will do that magic for you

    BOOL WINAPI FreeConsole(VOID);
    
    0 讨论(0)
  • 2021-02-01 05:59

    To literally hide/show the console window on demand, you could use the following functions: It's possible to hide/show the console by using ShowWindow. GetConsoleWindow retrieves the window handle used by the console. IsWindowVisible can be used to checked if a window (in that case the console) is visible or not.

    #include <Windows.h>
    
    void HideConsole()
    {
        ::ShowWindow(::GetConsoleWindow(), SW_HIDE);
    }
    
    void ShowConsole()
    {
        ::ShowWindow(::GetConsoleWindow(), SW_SHOW);
    }
    
    bool IsConsoleVisible()
    {
        return ::IsWindowVisible(::GetConsoleWindow()) != FALSE;
    }
    
    0 讨论(0)
  • 2021-02-01 06:01

    Just do that on startup

    myConsole = GetConsoleWindow();
    ShowWindow(myConsole,0);
    
    0 讨论(0)
提交回复
热议问题