Launch4j、NSIS 和重复的固定 Windows 7 任务栏图标

发布于 2024-10-27 16:03:16 字数 1379 浏览 8 评论 0原文

我遇到一个问题,当我在 Windows 7 中为我的应用程序固定任务栏图标时,单击该图标会为该程序打开一个单独的(重复)图标,而不是将其与用于调用它的快捷方式分组在一起。

该应用程序本身是一个 .jar 文件,已使用 Launch4j 打包到 .exe 中。这可以解释为什么图标会重复 - Launch4j 正在调用 javaw.exe 的单独进程,并且当您开始执行此类操作时,AppModelUserID 看起来会感到困惑。

根据 这篇文章,解决方案是指定您的 AppModelUserID 通过一些本机代码。我成功地按照那里给出的示例在我的应用程序中调用了 JNA 代码,而且我似乎将其正确设置为“MyCompany.MyApp”形式的值。调用“get”函数会返回我为其设置的值,因此应用程序端的一切似乎都正常。

...但这就是解决方案的终点!我不认为这就是结束,因为它肯定不能解决我的问题!看起来需要的是已创建的具有相同AppModelUserID的快捷方式——这是我对MSDN文档的解释。

由于我使用 NSIS 作为安装程序,因此我使用了 WinShell 用于在安装时设置应用程序快捷方式属性的插件。具体来说,该调用反映了以下示例:

WinShell::SetLnkAUMI "$SMPrograms\MyApp\MyApp.lnk" "${MyApp_AppUserModelId}"

这是我拖到任务栏的那个......但同样,没有骰子。该应用程序仍以单独的固定图标打开。此时,我无法检查是否正确设置了快捷方式属性,因为似乎没有工具可以检查给定快捷方式的 AppModelUserID 是什么。

当我直接创建 .jar 文件的快捷方式时,一切工作正常,但是尝试将 JRE 安装到 NSIS 中会遇到麻烦,以及我已经经历过并试图避免的大量其他令人头疼的问题。

我真的很感激任何可以帮助我解决这个棘手问题的指导!我总是被这些愚蠢的小美学问题困扰,解决起来非常痛苦……

谢谢!

编辑:通过切换到 NSISANSI 版本解决了这个问题,正如 Anders 在我之后所建议的那样无法验证快捷方式的 AppModelUserID 实际上是否已正确设置。

I'm having a problem wherein when I pin a taskbar icon in Windows 7 for my application, clicking the icon opens up a separate (duplicate) icon for the program instead of keeping it grouped with the shortcut used to call it.

The application itself is a .jar file that's been wrapped into an .exe using Launch4j. That would explain why the icon is getting duplicated -- Launch4j is calling a separate process of javaw.exe, and it looks like the AppModelUserID gets confused when you start doing stuff like that.

According to this post, the solution is to specify your AppModelUserID through some native code. I successfully got the JNA code being called within my application as per the example given there, and it would appear that I'm setting it properly to a value of the form "MyCompany.MyApp". Calling the 'get' function returns the value that I set for it, so everything appears to be OK on the application side.

... but that's where that solution stops! I don't think it's the end of it because it sure doesn't fix the problem for me! It would appear that what's also required is a shortcut that's been created that has the same AppModelUserID -- this is my interpretation of the MSDN documentation.

Since I'm using NSIS as my installer, I used the WinShell plugin to set the properties of the application shortcut upon install. Specifically, the call mirrors the example of:

WinShell::SetLnkAUMI "$SMPrograms\MyApp\MyApp.lnk" "${MyApp_AppUserModelId}"

That's the one I drag to the taskbar... but again, no dice. The application still opens in a separate pinned icon. At this point, I'm unable to check whether I've set the shortcut properties properly, because there doesn't seem to be a tool to check what the AppModelUserID is of a given shortcut.

Everything works fine when I just create a shortcut directly to the .jar file, but then there's the hassle of trying to implement the JRE install into NSIS and a ton of other headaches I've already been through and am trying to avoid.

I'd really appreciate any guidance that could help me to solve this nagging issue! I'm always plagued by these stupid little aesthetic issues that can be such a pain to solve...

Thanks!

EDIT: The problem was solved by switching to an ANSI build of NSIS, as recommended by Anders after I was unable to verify that the shortcut's AppModelUserID was in fact being set properly.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

提笔书几行 2024-11-03 16:03:16

在十六进制编辑器中打开 .lnk,AppModelUserId 应存储为 28 4C 9F 79 9F 39 4B A8 D0 E1 D4 2D E1 D5 F3 之后约 15 个字节的 unicode 字符串,

除非我的(内部)LNK 转储程序错误,否则 WinShell:: SetLnkAUMI 工作正常,问题可能不在于快捷方式,但为了确定,您应该正常启动应用程序并将其固定到任务栏,然后比较固定的 .lnk (%APPDATA%\Microsoft\Internet Explorer \Quick Launch\User Pinned\TaskBar)以及 NSIS 在十六进制编辑器中创建的快捷方式(它们可能不是 100% 相等,但您应该能够在两者中看到您的 AppModelUserId 作为 UTF16LE 字符串)


WinShell+lnk dump


HEX LNK

Open the .lnk in a hex editor, the AppModelUserId should be stored as a unicode string about 15 bytes after 28 4C 9F 79 9F 39 4B A8 D0 E1 D4 2D E1 D5 F3

Unless my (internal) LNK dumper is wrong, WinShell::SetLnkAUMI works correctly and the problem is probably not with the shortcut, but just to be sure, you should start your app normally and pin it to the taskbar and then compare the pinned .lnk (%APPDATA%\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar) with the shortcut created by NSIS in a hex editor (They might not be 100% equal but you should be able to see your AppModelUserId as a UTF16LE string in both)


WinShell+lnk dump


HEX LNK

浅语花开 2024-11-03 16:03:16

该库声称它可以使用正确的图标和名称将 Java 应用程序正确固定到 Windows 7 任务栏...

http ://www.strixcode.com/j7goodies/

请参阅 Microsoft 解释:

http://blogs.technet.com/b/deploymentguys/archive/2009/04/08 /pin-items-to-the-start-menu-or-windows-7-taskbar-via-script.aspx

SO中的解决方案:使用 JNA 获取/设置应用程序标识符

已编辑:

看来 InnoSetup 已经提供了从版本 5.3.5 开始,通过使用 [Icons] 部分下的条目的 AppUserModelID 参数来支持 Windows 7 跳转列表...这确实是这个烦人的救星问题...

仍然需要以下代码来告诉 Windows 7 该应用程序进程与 InnoSetup 创建的 Windows-7 兼容快捷方式共享相同的 AppUserModelID

//name: must match AppUserModelID name set in an entry under [Icons] section
shell32.SetCurrentProcessExplicitAppUserModelID(name);

通过此 InnoSetup 功能,它将自动允许固定和当检测到相同的 AppUserModelID 名称时进行分组。

请参阅http://copyandpastecode.blogspot .com/2010/07/windows-7-jump-list-not-appearing-on.html

This library claims that it can correctly pin Java application to the Windows 7 taskbar with the right icon and name...

http://www.strixcode.com/j7goodies/

See Microsoft explanation:

http://blogs.technet.com/b/deploymentguys/archive/2009/04/08/pin-items-to-the-start-menu-or-windows-7-taskbar-via-script.aspx

Solution in SO: Using JNA to get/set application identifier

Edited:

It seems that InnoSetup has provided support for Windows 7 Jump List since version 5.3.5 by using AppUserModelID parameter for an entry under [Icons] section...it is really a life-saver to this annoying issue...

The following code is still needed to tell Windows 7 that this application process shares the same AppUserModelID as the Windows-7 compatible shortcut created by InnoSetup

//name: must match AppUserModelID name set in an entry under [Icons] section
shell32.SetCurrentProcessExplicitAppUserModelID(name);

With this InnoSetup feature, it will automatically allow pinning and grouping when it detects the same AppUserModelID name.

see http://copyandpastecode.blogspot.com/2010/07/windows-7-jump-list-not-appearing-on.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文