我需要为同一个Application添加多个桌面链接,以提供不同的参数。
在“添加桌面链接”install4j操作中执行的java代码是什么?
(更新)
我找到了在Windows中创建简单桌面链接的代码。现在我使用for循环测试来创建具有不同参数的多个实例,但是在下一次执行的状态标志中,方法返回总是为false(我认为此方法不会刷新shortCut文件,并且在下一次迭代时会被阻止)。
这是代码:
import com.install4j.api.windows.WinFileSystem;
int[] listIndexDestinos = (int[])context.getVariable("listIndexDestinosSeleccionados"); //int array with indexs of javax.swing.JList selected
String[] listDestinosDisponibles = (String[])context.getVariable("listDestinosDisponibles");//String array with description for Destinations. Index related with previous array.
String installationDir = (String)context.getVariable("sys.installationDir");
String executableFile = "app.exe";
String executableAbsolutePath = installationDir + File.separatorChar + executableFile;
String iconsDir = installationDir + File.separatorChar + "icons" + File.separatorChar;
File shortcutTo = new File(executableAbsolutePath);
File startIn = new File(installationDir);
String strDesktopDir = (String)context.getVariable("sys.desktopDir");
for (int index : listIndexDestinos) {
String nombreConf = listDestinosDisponibles[index];
String iconName = "icon_" + index + ".ico";
String arguments = "-cfg "+index;
String descripcion = "APP - "+nombreConf;
String inkLocation = strDesktopDir + File.separatorChar + "App - " + nombreConf + ".lnk";
File inkFile = new File(inkLocation);
File iconFile = new File(iconsDir + iconName);
boolean created = WinFileSystem.createShellLink(inkFile,shortcutTo,iconFile,arguments,descripcion,startIn);
Util.showMessage("Crear acceso directo. inkLocation: "+inkLocation+". arguments: "+arguments+". created: "+created);
}
return true;