1

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

[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 位置,并提供了正确的路径,

有谁知道出了什么问题?

4

1 回答 1

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;
于 2013-10-12T19:08:35.657 回答