Launch4j,NSIS和重复固定的Windows 7任务栏图标 [英] Launch4j, NSIS, and duplicate pinned Windows 7 taskbar icons

查看:200
本文介绍了Launch4j,NSIS和重复固定的Windows 7任务栏图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

应用程序本身是一个.jar文件,它使用Launch4j包装到.exe中。这可以解释为什么图标会被复制 - Launch4j正在调用一个单独的javaw.exe进程,当你开始做这样的事情时,看起来像 AppModelUserID 会感到困惑。

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.

根据这篇文章 ,解决方案是通过一些本机代码指定 AppModelUserID 。我按照那里给出的示例成功地在我的应用程序中调用了JNA代码,看起来我正确地将它设置为MyCompany.MyApp形式的值。调用'get'函数会返回我为它设置的值,因此应用程序端的所有内容都显示为OK。

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.

...但这就是解决方案停止的地方!我不认为这是它的结束,因为它肯定不能解决我的问题!看来所需要的是一条创建的快捷方式,它具有相同 AppModelUserID - 这是我对MSDN文档的解释。

... 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.

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

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}"

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

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.

当我直接创建一个直接写入.jar文件的快捷方式时,一切正常,但是那时尝试在NSIS中实现JRE安装以及其他一些令人头疼的麻烦我都很麻烦已经过去了,我正试图避免。

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...

谢谢!

编辑切换到 ANSI NSIS 版本解决了问题,正如Anders在我无法验证快捷方式的AppModelUserID实际上是否正确设置之后。

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.

推荐答案

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

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

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

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)

这篇关于Launch4j,NSIS和重复固定的Windows 7任务栏图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆