gpt4 book ai didi

java - 从 Java 创建快捷链接 (.lnk)

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:40:40 26 4
gpt4 key购买 nike

我正在用 Java 编写安装程序(启动程序),并且需要能够在此过程中在用户桌面上创建快捷方式。

我对任何想法都感兴趣,认为这是最好的方法。我考虑过的一个选择是在 Windows 上使用 VB 脚本并使用 native “shortcut.exe”为我执行此操作,但首选第三方文件实用程序。

最佳答案

  /**
* Create an Internet shortcut
* @param name name of the shortcut
* @param where location of the shortcut
* @param target URL
* @param icon URL (ex. http://www.server.com/favicon.ico)
* @throws IOException
*/
public static void createInternetShortcut
(String name, String where, String target, String icon)
throws IOException
{
FileWriter fw = new FileWriter(where);
fw.write("[InternetShortcut]\n");
fw.write("URL=" + target + "\n");
if (!icon.equals("")) {
fw.write("IconFile=" + icon + "\n");
}
fw.flush();
fw.close();
}

完整示例在这里:Create an Internet Shortcut (Windows)

关于java - 从 Java 创建快捷链接 (.lnk),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3426314/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com