Search code examples
c++windowstaskbar

Hide A Console C++ Program From Taskbar


I have a little console game that calls another console app. Something like Winamp's many windows (main and playlist). The thing is when I call two for example console windows the programs opened in the taskbar get too many, I don't need to open the windows separately, I want only the main window to stay in the taskbar and when I click on it, it and all its child apps to pop up.

P.S. I am familiar with ShowWindow ( GetConsoleWindow(), SW_HIDE );, but it hides the window as well and I want it to be hidden only from the taskbar.


Solution

  • The only way I am aware of to accomplish this on a console window is to use the shell interface ITaskbarList.

    hr = CoCreateInstance(
        CLSID_TaskbarList,
        NULL,
        CLSCTX_INPROC_SERVER,
        IID_ITaskbarList,
        reinterpret_cast<void**>(&taskbar));
    if(!FAILED(hr))
    {
        // Remove the icon from the task bar
        taskbar->DeleteTab(GetConsoleWindow());
        // Release it
        taskbar->Release();
    }