如何创建目标快捷方式以将应用程序与正确的程序 - Inno Setup链接?

时间:2013-10-12 17:35:20

标签: inno-setup

我需要将idl虚拟机添加到我的IDL .sav文件的Target位置 我正在使用Inno Setup, 以下代码行

[Icons]
Name: "{group}\clas";  Filename:  "{code:GetIDLPath}"; Parameters: """{app}\bin\BATCH_CLAS_MAIN.sav"""; IconFilename: "{app}\clas_icon.ico"

[Code]
function GetIDLPath(dummy: string): string;
begin
  RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\idlrt.exe', '', Result);
  if Result = '' then
    Result := 'idlrt.exe';
end;

但目标位置最终成为:

C:\clas\bin\BATCH_CLAS_MAIN.sav

应该是:

"C:\Program Files\Exelis\IDL82\bin\bin.x86\idlrt.exe" -vm C:/clas/bin/BATCH_CLAS_MAIN.sav

我检查了注册表中的idlrt.exe位置,我提供了正确的路径,

有谁知道什么是错的?

1 个答案:

答案 0 :(得分:1)

至少我可以看到Parameters参数值有问题。如果传递可扩展的-vm常量,则无法使用{app}/bin/BATCH_CLAS_MAIN.sav选项后跟带有正斜杠的"{app}\bin\BATCH_CLAS_MAIN.sav"路径获得预期结果。这可能会更好一点:

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName=My Program

[Icons]
; because of use of the "useapppaths" flag, there's no need to have the
; GetIDLPath function anymore; that flag do its work for you
Name: "{group}\clas"; Filename: "idlrt.exe"; Parameters: "{code:GetIDLParams}"; IconFilename: "{app}\clas_icon.ico"; Flags: useapppaths

[Code]
function GetIDLParams(Value: string): string;
begin
  // prepare the -vm option followed by a quoted application path to a file
  Result := '-vm ' + AddQuotes(ExpandConstant('{app}\bin\BATCH_CLAS_MAIN.sav'));
  // and replace backslashes to forward slashes
  StringChangeEx(Result, '\', '/', False);
end;