在 Windows 7 中的系统托盘应用程序上维护用户可见性首选项
我有一个通过 ClickOnce 部署到网络共享的应用程序。我将安装模式设置为仅在线。该应用程序在系统托盘中运行。在 Windows 7 中,当程序首次运行时,它将显示在扩展系统托盘中(您必须先单击箭头才能找到该项目)。问题是,当用户设置其首选项以使应用程序显示在主托盘中时,当我发布更新时,首选项将丢失。然后我的应用程序将在首选项中显示两次(一次是旧版本,已设置为在主托盘中显示,另一次是新版本,未设置为在主托盘中显示。我怎样才能得到它以便他们只需设置一次首选项即可显示?
I have an application that is deployed via ClickOnce to a network share. I have the install mode set to online only. The application runs in the system tray. In Windows 7, when the program is first ran, it will show up in the extended system tray (the one where you have to click on the arrows first to get to the item). The problem is that when a user sets their preferences to have the application show up in the main tray the preferences will get lost when I publish an update. Then my application will show up twice in the preferences (once for the old version which has it set to show in the main tray and another which is the new version which is not set to show up in the main tray. How can I get it to work so that they only have to set their preferences once to get it to show?
There is a similar question here: http://social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/c33ab558-7fd5-4330-a985-9702358472d0/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这实际上是可以完成的(即,即使 ClickOnce 在更新期间更改了可执行文件的路径,您也可以使 Windows 7 将通知图标识别为同一个图标)。它只是非常挑剔,并且要求以下每一个条件都满足严格的精度:
如果无论路径如何,都没有保存设置 - 或者 - Shell_NotifyIcon 开始向您抛出错误,这意味着:
如果您在某个时刻搞砸了并且 Shell_NotifyIcon 开始返回 false 并且似乎不会停止,请生成一个新的 GUID 以重新启动该过程。
另请注意:当您尝试执行有关带有 GUID 的通知图标的任何操作时,请检查操作系统版本,确保您使用的是 Windows 7 或更高版本。 Windows Vista 及更低版本将会崩溃。
例子:
This actually can be done (i.e. you can make Windows 7 recognize the notification icon as being the same one even though ClickOnce has changed the path of your executible during an update). It's just very finicky and requires that every single one of the below criteria are met with exacting precision:
If the settings are not being saved regardless of path -OR- Shell_NotifyIcon starts tossing false back at you, that means either:
If you mess up at some point and Shell_NotifyIcon starts returning false and just won't seem to stop, generate a new GUID to start the process over again.
Also Note: Check the OS version to make sure you're on Windows 7 or above when ever you try to do anything concerning a notify icon with a GUID. Windows Vista and below will freak out.
Example:
我们的应用程序曾经有一个通知图标。我们的问题是,除非用户将所有通知设置为始终显示,否则它不会显示。如果用户有一段时间没有运行该应用程序,然后再运行它,它将不再显示,直到他们使用它几次。
我不知道有什么方法可以解决这个问题。由于这个原因以及一些商业原因,我们最终将其删除。
We used to have a notifyicon for our application. Our problem was it wouldn't show it unless the user set all of the notifications to show all the time. If the user didn't run the app for a while, and then ran it, it would no longer be displayed until they used it several times.
I don't know of any way to work around this. We ended up taking it out for this reason as well as some business reasons.