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.
Thanks to Captain Obvlious and some research, the following code:
ITaskbarList *pTaskList = NULL;
HRESULT initRet = CoInitialize(NULL);
HRESULT createRet = CoCreateInstance( CLSID_TaskbarList,
                                      NULL,
                                      CLSCTX_INPROC_SERVER,
                                      IID_ITaskbarList,
                                      (LPVOID*)&pTaskList );
if(createRet == S_OK)
{
    pTaskList->DeleteTab(GetConsoleWindow());
    pTaskList->Release();
}
CoUninitialize();
with included ShObjIdl.h works great!
Note: You should get S_OK as a value in initRet and createRet!
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();
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With