我在电脑上同时运行了5个不同的C#应用程序。它们占据了我的任务栏很多空间。我该如何编写代码使它们在任务栏上分组显示(使用Windows 10)。
我在电脑上同时运行了5个不同的C#应用程序。它们占据了我的任务栏很多空间。我该如何编写代码使它们在任务栏上分组显示(使用Windows 10)。
您需要使用pinvoke调用SetCurrentProcessExplicitAppUserModelID()
,为所有希望共享任务栏按钮的应用程序提供相同的AppID。操作系统将把这5个应用程序视为同一应用程序。
请确保在显示任何应用程序用户界面之前调用SetCurrentProcessExplicitAppUserModelID()。
[DllImport("shell32.dll", SetLastError=true)]
static extern void SetCurrentProcessExplicitAppUserModelID(
[MarshalAs( UnmanagedType.LPWStr )] string AppID );
private static string AppID = "some guid"; // use the same ID in all 5 apps
...
SetCurrentProcessExplicitAppUserModelID(AppID);
我没有尝试过这个,但您可能想查看TaskbarItemInfo类。 我认为属性ThumbButtonInfos可能是关键。
哦,我还在stackoverflow上找到了这个: 控制Windows 7任务栏分组以便应用程序可用
希望这有所帮助。