我目前正在尝试将 Java 应用程序固定到 Windows 7 任务栏。该应用程序通过 Launch4j 启动。程序图标显示正确,但右键单击任务栏上的图标仅显示带有“关闭窗口”条目的上下文菜单。没有用于将应用程序固定到任务栏的菜单条目。将 EXE 文件拖到任务栏也无法正常工作。当在任务栏中单击这个新的启动器时,任务栏中会出现第二个图标。
我按照这两个问题的解决方案的说明来解决问题,但没有帮助:
第二个问题中的 JNA 内容/解决方案编译并且不会引发任何异常。设置后我可以读取应用程序ID。但我仍然无法将应用程序固定到任务栏。
我在 Github 上创建了一个小型测试应用程序来演示该问题:
https://github.com/kayahr/launch4jtest< /a>
该应用程序使用 Maven 作为构建系统。只需运行mvn package
,您就会在目标目录中找到一个 ZIP 文件,其中包含 EXE 文件和设置此应用程序 ID 所需的 jna.jar。将此 ZIP 解压缩到某个目录,双击 EXE 并尝试将应用程序固定到任务栏,您就会看到问题。
那么这个应用程序有什么问题呢?
I'm currently trying to pin a Java application to the Windows 7 taskbar. The application is launched with Launch4j. The program icon is displayed correctly but right-clicking the icon on the taskbar only shows a context-menu with the entry "Close window". No menu entry for pinning the application to the taskbar. Dragging the EXE file into the taskbar is also not working properly. When clicking this new launcher in the taskbar then a second icon spawns in the taskbar.
I followed the instructions of the solutions to these two questions to solve the problem but it didn't help:
The JNA stuff from the second question/solution compiles and doesn't throw any exception. I can read the app id after setting it. But I still can't pin the application to the taskbar.
I have created a small test application on Github which demonstrates the problem:
https://github.com/kayahr/launch4jtest
The application uses Maven as build system. Simply run mvn package
and you'll find a ZIP file in the target directory which contains the EXE file and the jna.jar which is needed to set this app id. Extract this ZIP to some directory, double-click the EXE and try to pin the application to the taskbar and you'll see the problem.
So what's wrong with this application?
发布评论
评论(2)
注意:根据 kayahr 的要求重写了主帖中的一些评论:)
您需要创建一个嵌入 AppUserModelID 信息的图标快捷方式。 InnoSetup可以在
[Icons]
部分创建这样的图标快捷方式。提供通过 JNA 分配给 AppUserModelID 的应用程序名称。建议阅读的链接:如何制作 .exe 文件izpack 安装程序 .jar 文件
Launch4j、NSIS 和重复的固定 Windows 7 任务栏图标
要在 Linux 下运行基于 Windows 的安装程序生成器,请参阅此作为指南:
http://katastrophos.net/andre/blog/2009/03/16/setting-up-the-inno-setup-compiler-on-debian/
是的,正如提到的kayahr,这个 Windows 7 功能只有在嵌入 AppUserModelID 的图标快捷方式保持不变(即没有被删除/删除)时才起作用。
N.B. Rewritten some comments originally in the main post as per kayahr's request :)
You need to create an icon shortcut that embeds AppUserModelID information. InnoSetup can create such icon shortcut under
[Icons]
section. Supply the application name assigned to AppUserModelID via JNA. Suggested links to read:How to make .exe file for izpack installer .jar file
Launch4j, NSIS, and duplicate pinned Windows 7 taskbar icons
To run Windows-based installer builder under Linux, refer this as a guide:
http://katastrophos.net/andre/blog/2009/03/16/setting-up-the-inno-setup-compiler-on-debian/
Yes, as mentioned by kayahr, this Windows 7 feature will only work when its icon shortcut with embedded AppUserModelID remains intact (i.e. it is not removed/deleted).
我使用 InnoSetup 为我的 java 应用程序创建安装程序。要使我的应用程序的图标可固定,我执行两个步骤:
从 Maven 添加包:net.java.dev.jna/jna-platform-5.7.0
set AppUserModelID
WString id = new WString("TMP.TestApp");
Shell32.INSTANCE.SetCurrentProcessExplicitAppUserModelID(id);
使用 InnoSetup 创建图标时使用 AppUserModelID
[图标]
名称:“{commondesktop}\TestApp”;文件名:“{app}\run.bat”;工作目录:“{app}”;图标文件名:“{app}\test-icon.ico”; AppUserModelID: "TMP.TestApp";标志:运行最小化
I use InnoSetup to create installer for my java application. To make my app's icon pinable I do two steps:
Add package from Maven: net.java.dev.jna/jna-platform-5.7.0
set AppUserModelID
WString id = new WString("TMP.TestApp");
Shell32.INSTANCE.SetCurrentProcessExplicitAppUserModelID(id);
Use AppUserModelID when creating icon with InnoSetup
[Icons]
Name: "{commondesktop}\TestApp"; Filename: "{app}\run.bat"; WorkingDir: "{app}";IconFilename:"{app}\test-icon.ico"; AppUserModelID: "TMP.TestApp"; Flags: runminimized