如何在 Windows 中*默认*始终显示程序托盘图标?
如果程序在 Windows 7 中第一次执行,它会自动隐藏图标。 是否有任何清单设置或选项可以强制 Windows 7 默认情况下始终显示该图标?
If a program is executed for the first time in Windows 7, it automatically hides the icon. Is there any manifest setting or option to force Windows 7 to always show the icon by default?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不久前,微软的 Kate Gregory 在 .NET Rocks 播客中表示,这是不可能的。
她说:“如果用户想要它(托盘图标),他/她会把它放在那里”。
这样做的原因是为了防止托盘区域混乱。
In .NET Rocks podcast, not long time ago, Kate Gregory from Microsoft was saying that it is impossible.
She said something like: "If user wants it (tray icon) he/she will put it there".
Reason for this is to prevent mess in the tray area.
如果您确实想显示托盘图标,您可以弹出一个带有最少文本的气球,然后通过以下代码示例再次隐藏气球和它的阴影:
如果您重复此操作(例如每 30 秒),您的托盘图标将保留因为 Explorer.exe 认为有一个气球打开以向用户显示。 一些小问题 - 例如无法直接右键单击图标 - 仍然存在。
我确实习惯于显示我们公司软件的托盘图标,用户不打算在每次更新时手动执行此操作。 所以也许这会对某人有所帮助...:)
否则,我完全同意:这应该只在用户手中,而不是由应用程序控制。
If you really want to show your tray-icon, you can popup a balloon with minimal text and just afterwards hide the balloon and it's shadow again by following code-example:
if you repeat this (e.g. every 30 seconds), your trayicon will stay there because Explorer.exe thinks, there is a balloon open to display to the user. A few minor issues - such as no right-click directly on icon - are still there.
I really used to show the tray icon for our company-software where the user are not intended to do this manually and for each update. So maybe this will help someone... :)
Otherwise, I totally agree: This should be only in hands of the user, not controlled by the application.
这当然不是“不可能”。 有一个未记录的 COM 接口
ITrayNotify
,用于检索托盘图标并更改其可见性,由 Explorer 本身使用。 完整的 C++ 源代码在这里: http://thread0.me/tag/windows/当然,使用非官方 API 有风险,Windows 8 对此 API 进行了重大更改,这意味着您必须对 XP 使用 2 种不同的定义 - Win7 和 Win8 - Win10。 不过,嘿,即使 Chrome 也使用此功能技巧。 只要确保正确处理故障即可。
It's certainly not "impossible". There is an undocumented COM interface
ITrayNotify
for retrieving tray icons and changing their visibility, used by Explorer itself. Full C++ source here: http://thread0.me/tag/windows/Of course, using an unofficial API is risky and Windows 8 has intoduced breaking changes to this API, which means you have to use 2 different definitions for XP - Win7 and Win8 - Win10. But hey, even Chrome uses this trick. Just be sure to handle failures properly.