16

在 IS 新闻组中建议使用 /D=,但使用 5.2.3 版附带的 iscc.exe 我收到“未知选项:”错误。

那么在脚本中,如何使用命令行参数的值呢?

4

3 回答 3

24

正如 MicSim 所说,你确实需要预处理器。它包含在最新的 ISPack 中。安装后,iscc 支持 /D。

然后,您可以使用这样定义的值(假设您已完成 /DVERSION_NAME=1.23):

AppVerName=MyApplication v{#VERSION_NAME}
于 2009-02-04T22:21:16.097 回答
5

从 Inno Setup 帮助文件:

Inno Setup Preprocessor 用扩展版本替换了标准的 Inno Setup Command Line Compiler (ISCC.exe)。这个扩展版本提供了额外的参数来控制 Inno Setup Preprocessor。

“额外参数”包括 /d 选项。

于 2009-02-04T22:20:54.507 回答
-1

如果要从 inno 中的代码中解析命令行参数,请使用与此类似的方法。只需从命令行调用 inno 脚本,如下所示:

C:\MyInstallDirectory>MyInnoSetup.exe -myParam parameterValue

然后,您可以在需要的任何地方调用 GetCommandLineParam:

myVariable := GetCommandLineParam('-myParam');

//================================================= ===================

{ Allows for standard command line parsing assuming a key/value organization }
function GetCommandlineParam (inParam: String):String;
var
  LoopVar : Integer;
  BreakLoop : Boolean;
begin
  { Init the variable to known values }
  LoopVar :=0;
  Result := '';
  BreakLoop := False;

  { Loop through the passed in arry to find the parameter }
  while ( (LoopVar < ParamCount) and
          (not BreakLoop) ) do
  begin
    { Determine if the looked for parameter is the next value }
    if ( (ParamStr(LoopVar) = inParam) and
         ( (LoopVar+1) < ParamCount )) then
    begin
      { Set the return result equal to the next command line parameter }
      Result := ParamStr(LoopVar+1);

      { Break the loop }
      BreakLoop := True;
    end

    { Increment the loop variable }
    LoopVar := LoopVar + 1;
  end;
end;

希望这可以帮助...

于 2011-03-03T15:12:13.237 回答