我正在用 Java 编写一个安装程序(启动器),并且需要能够在此过程中在用户桌面上创建快捷方式。
我对任何想法都感兴趣,认为这是实现这一目标的最佳方法。我考虑过的一个选择是在 Windows 上使用 VB 脚本并使用本机“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();
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)