在Inno Setup中传递条件参数 [英] Passing conditional parameter in Inno Setup

查看:277
本文介绍了在Inno Setup中传递条件参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Inno Setup的新手,我已经阅读了文档.现在,我知道Inno Setup可以接受其他/自定义参数,并且可以通过Pascal脚本进行处理.但是问题是,我不知道如何用Pascal编写.

I am new to Inno Setup and I have already read the documentation. Now I know that Inno Setup can accept different/custom parameter and could be processed via Pascal script. But the problem is, I don't know how to write in Pascal.

我希望我可以在编码方面获得帮助.

I am hoping I could get help about the coding.

我想将/NOSTART参数传递给我的安装文件,该文件告诉安装程序禁用(取消选中)启动"上的复选标记,如果未提供/NOSTART,它将启用(检查)选中标记为启动"

I'd like to pass /NOSTART parameter to my setup file which while tell the setup to disable(uncheck) the check mark on "Launch " and if /NOSTART is not provided, it it will enable(check) the check mark "Launch "

,或者如果可能的话,不需要启动页面,而是通过代码完成所有操作.

or if possible, that Launch page is not required and do everything via code.

推荐答案

,所以我读了一些研究,然后读了..我得到了答案.

and so a little research read and read .. i got my answer.

这是我的代码("GetCommandLineParam"除外)

here's my code (except the "GetCommandLineParam")

[Code]
{
var
  StartNow: Boolean;
}

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;

{
function InitializeSetup(): Boolean;
var
  NOSTART_Value : String;

begin
  NOSTART_Value := GetCommandLineParam('/NOSTART');

  if(NOSTART_Value = 'false') then
    begin
      StartNow := True
    end
  else
    begin
      StartNow := False
    end;

  Result := True;
end;
}

procedure CurStepChanged(CurStep: TSetupStep);
var
  Filename: String;
  ResultCode: Integer;
  NOSTART_Value : String;
begin
  if CurStep = ssDone then
    begin
      NOSTART_Value := GetCommandLineParam('/NOSTART');
      if(NOSTART_Value = 'false') then
        begin
          Filename := ExpandConstant('{app}\{#MyAppExeName}');
          Exec(Filename, '', '', SW_SHOW, ewNoWait, Resultcode);
        end
    end;
end;

代码更新.感谢@TLama

a code update. Thanks to @TLama

function CmdLineParamExists(const Value: string): Boolean;
var
  I: Integer;  
begin
  Result := False;
  for I := 1 to ParamCount do
    if CompareText(ParamStr(I), Value) = 0 then
    begin
      Result := True;
      Break;
    end;
end;

procedure CurStepChanged(CurStep: TSetupStep);
var
  Filename: String;
  ResultCode: Integer;
  NOSTART_Value : String;
  RunApp : Boolean;
begin
  if CurStep = ssDone then
    begin
      RunApp := CmdLineParamExists('/START');
      if(RunApp = True) then
        begin
          Filename := ExpandConstant('{app}\{#MyAppExeName}');
          Exec(Filename, '', '', SW_SHOW, ewNoWait, Resultcode);
        end

      // NOSTART_Value := GetCommandLineParam('/START');
      // if(NOSTART_Value = 'true') then
        // begin
          // Filename := ExpandConstant('{app}\{#MyAppExeName}');
          // Exec(Filename, '', '', SW_SHOW, ewNoWait, Resultcode);
        //end
    end;
end;

这篇关于在Inno Setup中传递条件参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆