Combine two applications into one icon on taskbar

2019-08-04 04:53发布

问题:

I have two applications. One is the main application and the other is the updater.

A user launches with the updater - if an update is available it will download and extract, otherwise it will just launch the main application. I used two applications for this so that I am able to overwrite the main applcation.

The issue is that the users have pinned the "Launcher" application on their taskbar, but when the main application launches it is not grouped under that icon and very confusing for them.

Is there any way around this?

回答1:

You should be able to do that using Windows API Code Pack.

You need to use Microsoft.WindowsAPICodePack.Taskbar namespace from the Microsoft.WindowsAPICodePack.Shell assembly.

Call TaskbarManager.Instance.SetApplicationIdForSpecificWindow( window, string appId ); method. You can specify either an IntPtr windows handle if you're using WinForms, or a Window instance if you're using WPF.

Do this step in both your processes immediately after launch, and specify the same appId for both.



回答2:

you can refer [ How to group my apps in windows taskbar? ] of George's answer, by forcefully make two process share the same APP_ID(string) simply by calling shell32!SetCurrentProcessExplicitAppUserModelID at each process's main()