如何将我的应用程序与Windows 7任务栏上的固定程序相关联?

时间:2022-01-20 20:26:40

We have an application, let's call it MyApp. On installation, we create a desktop icon for MyApp, which basically calls MyLauncher.exe /launch MyApp.exe. MyLauncher does some useful stuff (check for updates, etc.), and then starts MyApp.

我们有一个应用程序,我们称之为MyApp。在安装时,我们为MyApp创建一个桌面图标,它基本上调用MyLauncher.exe /启动MyApp.exe。 MyLauncher做了一些有用的东西(检查更新等),然后启动MyApp。

如何将我的应用程序与Windows 7任务栏上的固定程序相关联?

A user with Windows 7 might want to pin it to the task bar (i.e., right mouse button on the desktop icon, "Pin to Taskbar"):

Windows 7的用户可能希望将其固定到任务栏(即桌面图标上的鼠标右键,“Pin to Taskbar”):

如何将我的应用程序与Windows 7任务栏上的固定程序相关联?

However, since the shortcut points to MyLauncher, the following happens when the user starts the application (either with the desktop icon or the taskbar icon): MyLauncher does its stuff, and, afterwards, it starts MyApp. On the taskbar, the result is as follows:

但是,由于快捷方式指向MyLauncher,当用户启动应用程序时(使用桌面图标或任务栏图标)会发生以下情况:MyLauncher执行其操作,然后启动MyApp。在任务栏上,结果如下:

如何将我的应用程序与Windows 7任务栏上的固定程序相关联?

I understand why this happens. Since MyLauncher starts MyApp, the Windows 7 taskbar sees them as two different applications.

我明白为什么会这样。由于MyLauncher启动了MyApp,因此Windows 7任务栏将它们视为两个不同的应用程序。

Obviously, my question is: As the developer of MyLauncher and MyApp, can I do something about this? I'd like the Windows 7 taskbar to "associate" all instances of MyApp.exe with the shortcut starting MyLauncher.exe /lauch MyApp.exe.

显然,我的问题是:作为MyLauncher和MyApp的开发人员,我能为此做些什么吗?我希望Windows 7任务栏将MyApp.exe的所有实例与启动MyLauncher.exe / lauch MyApp.exe的快捷方式“关联”。

3 个解决方案

#1


3  

Try playing around with the "App Ids" See here for more info: http://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx

尝试使用“App Ids”查看更多信息:http://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v = vs.85).aspx

"Application User Model IDs (AppUserModelIDs) are used extensively by the taskbar in Windows 7 and later systems to associate processes, files, and windows with a particular application. In some cases, it is sufficient to rely on the internal AppUserModelID assigned to a process by the system. However, an application that owns multiple processes or an application that is running in a host process might need to explicitly identify itself so that it can group its otherwise disparate windows under a single taskbar button and control the contents of that application's Jump List."

“应用程序用户模型ID(AppUserModelIDs)被Windows 7及更高版本系统中的任务栏广泛使用,以将进程,文件和窗口与特定应用程序相关联。在某些情况下,依赖分配给进程的内部AppUserModelID就足够了但是,拥有多个进程的应用程序或在主机进程中运行的应用程序可能需要明确标识自身,以便它可以在单个任务栏按钮下对其他不同的窗口进行分组,并控制该应用程序的跳转内容列表“。

#2


0  

One thing you can do is not show the task-bar icon for the application at all. In WPF it's as simple as a property setting:

您可以做的一件事就是不显示应用程序的任务栏图标。在WPF中,它就像属性设置一样简单:

ShowInTaskbar="False"

ShowInTaskbar = “假”

The problem with this approach is that it will reduce usability because the user can no longer tell when the application is running or easily bring it to the forefront when it gets lost behind other windows. In order to alleviate some of these concerns, you can create a notify icon for this application which would enable some of these functions and also give the user some feedback as to the application's current state. (Running, not running, etc..)

这种方法的问题在于它会降低可用性,因为用户无法再知道应用程序何时运行,或者当它在其他窗口后面丢失时很容易将其带到最前端。为了缓解这些问题,您可以为此应用程序创建一个通知图标,该图标将启用其中一些功能,并向用户提供有关应用程序当前状态的一些反馈。 (跑步,不跑等)

This msdn resource has a good code sample on how to create notify icons in windows forms. You can use the same method for WPF applications as well.

这个msdn资源有一个关于如何在Windows窗体中创建通知图标的良好代码示例。您也可以对WPF应用程序使用相同的方法。

如何将我的应用程序与Windows 7任务栏上的固定程序相关联?

SMALL TIP: Notify icons are 16x16 pixels. Try to find a vector version of the icon prior to resizing as this will give you crisper results because you tend to lose a lot of detail at that size.

小提示:通知图标为16x16像素。在调整大小之前尝试找到图标的矢量版本,因为这会给你带来更加清晰的结果,因为你会在这个尺寸上丢失很多细节。

Some user interaction with the notify-icon can include:

一些用户与notify-icon的交互可以包括:

  • Double-Click > Brings the application to the front
  • 双击>将应用程序置于前面
  • Right-Click > Brings up a context menu with some choices. (I.E. Bring to front, close, etc...)
  • 右键单击>显示包含一些选项的上下文菜单。 (I.E.带到前面,关闭等......)
  • Mouse-Over > Brings up a tool-tip with some information regarding the application.
  • 鼠标悬停>显示一个工具提示,其中包含有关应用程序的一些信息。

#3


0  

1)
This is more of an architectural question / problem - that's a bit of an unusual design for such purposes,
i.e. if an updater (I'm guessing you have more but to start w/ that) is required that's usually checked within the app - then if update is deemed you start an outside process and update the app etc.
Launcher (as described) would make sense if you are launching many different things or you have a generic solution or in more complex cases - e.g. you have a 'host process' that loads dll-s, services etc.
So basically you're running into problems because of a bit unfortunate design, decision - unless you have something that warrants that sufficiently.
But having you said that you didn't wish to redesign...
2)
You could still do a 'trick' with launcher - and make kind of a simple work around...

1)这更像是一个架构问题/问题 - 对于这样的目的来说这是一个不寻常的设计,即如果一个更新程序(我猜你有更多,但开始那个)是必需的,通常在应用程序内检查 - 如果更新被视为你开始一个外部过程并更新应用程序等。启动器(如上所述)是有意义的,如果你发布了许多不同的东西或你有一个通用的解决方案或更复杂的情况 - 如你有一个加载dll-s,服务等的“主机进程”。所以基本上你遇到了问题,因为有点不幸的设计,决定 - 除非你有足够的保证。但是你说你不想重新设计...... 2)你仍然可以用发射器做一个“技巧” - 并做一个简单的工作......

  • Launch the 'MyApp -argument:check' first (and have icon on desktop belong to it, not the launcher), and have an argument 'fork' on startup and if 'check' do a small 'shim' code which lauches the 'MyLauncher',
  • 首先启动'MyApp -argument:check'(桌面上的图标属于它,而不是启动器),并在启动时有一个参数'fork',如果'check'执行一个小的'shim'代码,它会启动' MyLauncher”,
  • get the launcher to do what it's supposed to be doing - you can even close the main MyApp after launching,
  • 让启动器做它应该做的事情 - 你甚至可以在启动后关闭主MyApp,
  • when launcher is done it launches the MyApp again (or more complex to close if left only if update is needed etc. - but the previous is easier), and use some other argument or don't use any (depends on what you want etc.),
  • 当启动器完成时它会再次启动MyApp(或者更复杂以关闭,如果只有在需要更新时才会关闭等等 - 但前一个更容易),并使用其他参数或不使用任何(取决于你想要的等等) 。),
  • You're doing some process double redirection of a sort - start app => launcher => app again,
  • 你正在做一些进程双重定向排序 - 再次启动app => launcher => app,
  • you should have no problems with the icons this way,
  • 你应该没有问题这样的图标,
  • with all this you should be careful about supplying proper manifests to either app (most often the launcher which needs to update, more permissions) if an 'admin' mode is required, but I guess you have that already,
  • 如果需要“管理员”模式,你应该小心为这两个应用程序(通常是需要更新的启动器,更多权限)提供适当的清单,但我想你已经有了,

that might do the trick, haven't tried but I don't see why it shouldn't - and you can keep the existing architecture in place etc.

可能会做的伎俩,没有尝试,但我不明白为什么它不应该 - 并且你可以保持现有的架构等。

#1


3  

Try playing around with the "App Ids" See here for more info: http://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx

尝试使用“App Ids”查看更多信息:http://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v = vs.85).aspx

"Application User Model IDs (AppUserModelIDs) are used extensively by the taskbar in Windows 7 and later systems to associate processes, files, and windows with a particular application. In some cases, it is sufficient to rely on the internal AppUserModelID assigned to a process by the system. However, an application that owns multiple processes or an application that is running in a host process might need to explicitly identify itself so that it can group its otherwise disparate windows under a single taskbar button and control the contents of that application's Jump List."

“应用程序用户模型ID(AppUserModelIDs)被Windows 7及更高版本系统中的任务栏广泛使用,以将进程,文件和窗口与特定应用程序相关联。在某些情况下,依赖分配给进程的内部AppUserModelID就足够了但是,拥有多个进程的应用程序或在主机进程中运行的应用程序可能需要明确标识自身,以便它可以在单个任务栏按钮下对其他不同的窗口进行分组,并控制该应用程序的跳转内容列表“。

#2


0  

One thing you can do is not show the task-bar icon for the application at all. In WPF it's as simple as a property setting:

您可以做的一件事就是不显示应用程序的任务栏图标。在WPF中,它就像属性设置一样简单:

ShowInTaskbar="False"

ShowInTaskbar = “假”

The problem with this approach is that it will reduce usability because the user can no longer tell when the application is running or easily bring it to the forefront when it gets lost behind other windows. In order to alleviate some of these concerns, you can create a notify icon for this application which would enable some of these functions and also give the user some feedback as to the application's current state. (Running, not running, etc..)

这种方法的问题在于它会降低可用性,因为用户无法再知道应用程序何时运行,或者当它在其他窗口后面丢失时很容易将其带到最前端。为了缓解这些问题,您可以为此应用程序创建一个通知图标,该图标将启用其中一些功能,并向用户提供有关应用程序当前状态的一些反馈。 (跑步,不跑等)

This msdn resource has a good code sample on how to create notify icons in windows forms. You can use the same method for WPF applications as well.

这个msdn资源有一个关于如何在Windows窗体中创建通知图标的良好代码示例。您也可以对WPF应用程序使用相同的方法。

如何将我的应用程序与Windows 7任务栏上的固定程序相关联?

SMALL TIP: Notify icons are 16x16 pixels. Try to find a vector version of the icon prior to resizing as this will give you crisper results because you tend to lose a lot of detail at that size.

小提示:通知图标为16x16像素。在调整大小之前尝试找到图标的矢量版本,因为这会给你带来更加清晰的结果,因为你会在这个尺寸上丢失很多细节。

Some user interaction with the notify-icon can include:

一些用户与notify-icon的交互可以包括:

  • Double-Click > Brings the application to the front
  • 双击>将应用程序置于前面
  • Right-Click > Brings up a context menu with some choices. (I.E. Bring to front, close, etc...)
  • 右键单击>显示包含一些选项的上下文菜单。 (I.E.带到前面,关闭等......)
  • Mouse-Over > Brings up a tool-tip with some information regarding the application.
  • 鼠标悬停>显示一个工具提示,其中包含有关应用程序的一些信息。

#3


0  

1)
This is more of an architectural question / problem - that's a bit of an unusual design for such purposes,
i.e. if an updater (I'm guessing you have more but to start w/ that) is required that's usually checked within the app - then if update is deemed you start an outside process and update the app etc.
Launcher (as described) would make sense if you are launching many different things or you have a generic solution or in more complex cases - e.g. you have a 'host process' that loads dll-s, services etc.
So basically you're running into problems because of a bit unfortunate design, decision - unless you have something that warrants that sufficiently.
But having you said that you didn't wish to redesign...
2)
You could still do a 'trick' with launcher - and make kind of a simple work around...

1)这更像是一个架构问题/问题 - 对于这样的目的来说这是一个不寻常的设计,即如果一个更新程序(我猜你有更多,但开始那个)是必需的,通常在应用程序内检查 - 如果更新被视为你开始一个外部过程并更新应用程序等。启动器(如上所述)是有意义的,如果你发布了许多不同的东西或你有一个通用的解决方案或更复杂的情况 - 如你有一个加载dll-s,服务等的“主机进程”。所以基本上你遇到了问题,因为有点不幸的设计,决定 - 除非你有足够的保证。但是你说你不想重新设计...... 2)你仍然可以用发射器做一个“技巧” - 并做一个简单的工作......

  • Launch the 'MyApp -argument:check' first (and have icon on desktop belong to it, not the launcher), and have an argument 'fork' on startup and if 'check' do a small 'shim' code which lauches the 'MyLauncher',
  • 首先启动'MyApp -argument:check'(桌面上的图标属于它,而不是启动器),并在启动时有一个参数'fork',如果'check'执行一个小的'shim'代码,它会启动' MyLauncher”,
  • get the launcher to do what it's supposed to be doing - you can even close the main MyApp after launching,
  • 让启动器做它应该做的事情 - 你甚至可以在启动后关闭主MyApp,
  • when launcher is done it launches the MyApp again (or more complex to close if left only if update is needed etc. - but the previous is easier), and use some other argument or don't use any (depends on what you want etc.),
  • 当启动器完成时它会再次启动MyApp(或者更复杂以关闭,如果只有在需要更新时才会关闭等等 - 但前一个更容易),并使用其他参数或不使用任何(取决于你想要的等等) 。),
  • You're doing some process double redirection of a sort - start app => launcher => app again,
  • 你正在做一些进程双重定向排序 - 再次启动app => launcher => app,
  • you should have no problems with the icons this way,
  • 你应该没有问题这样的图标,
  • with all this you should be careful about supplying proper manifests to either app (most often the launcher which needs to update, more permissions) if an 'admin' mode is required, but I guess you have that already,
  • 如果需要“管理员”模式,你应该小心为这两个应用程序(通常是需要更新的启动器,更多权限)提供适当的清单,但我想你已经有了,

that might do the trick, haven't tried but I don't see why it shouldn't - and you can keep the existing architecture in place etc.

可能会做的伎俩,没有尝试,但我不明白为什么它不应该 - 并且你可以保持现有的架构等。