How to separate processes or windows of the same executable in the TaskBar

To set a different ApplicationId for each process using SetCurrentProcessExplicitAppUserModelID API.

You should change appID in each call (e.g.: add something that cannot be the same like GetTickCount) LPCTSTR appId[100];

_stprintf_s(appId, _T("SomeId%d"), ::GetTickCount());

HRESULT hr = SetCurrentProcessExplicitAppUserModelID(appID);

To set a different AppId for each top-level window in a process you can use SHGetPropertyStoreForWindow API:

IPropertyStore *pps; HRESULT hr = SHGetPropertyStoreForWindow(hWnd, IID_PPV_ARGS(&pps)); if (SUCCEEDED(hr)) {

   PROPVARIANT pv;
   if (iAppID >= 0)
   {
       hr = InitPropVariantFromString(appId, &pv);
   }
   else
   {
       PropVariantInit(&pv);
   }
   if (SUCCEEDED(hr))
   {
       hr = pps->SetValue(PKEY_AppUserModel_ID, pv);
       PropVariantClear(&pv);
   }
   pps->Release();

}

If you want to prevent you top-level windows to be grouped in the taskbar you should set a different appId for each top-level window.


Comments