问题
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()
回答3:
It was already mentioned to set the Application user Model ID.
But then you still have the problem that when the Application is pinned, it will not pin to the Launcher. But there is also a solution for this, that the Launcher/Updater is pinned instead of the Application: Pinning to the taskbar a "chained process"
来源:https://stackoverflow.com/questions/25393875/combine-two-applications-into-one-icon-on-taskbar