如何在Inno Setup的[Run]部分中传递自定义参数? 当我使用下面的代码时,exe能够获取参数,但我无法得到值,它是空白的。
以下是我的代码
[Run]
Filename: {tmp}\v1700sp3.exe; Parameters: "/APPCONFIGPATH= jjh"; Flags: skipifdoesntexist
以下是我调用exe
的代码[Code]
function GetCommandLineParam(inParam: String): String;
var
LoopVar : Integer;
BreakLoop : Boolean;
begin
{ Init the variable to known values }
LoopVar :=0;
Result := '';
BreakLoop := False;
//RaiseException('ParamCount ' + IntToStr(ParamCount) + ', inParam - ' + inParam )
MsgBox(IntToStr(ParamCount), mbInformation, MB_OK);
{ Loop through the passed in arry to find the parameter }
while ( (LoopVar < ParamCount) and
(not BreakLoop) ) do
begin
MsgBox(ParamStr(LoopVar), mbInformation, MB_OK);
{ 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;
procedure CurStepChanged(CurStep: TSetupStep);
var
Filename: String;
ResultCode: Integer;
APPCONFIGPATH_Value : String;
begin
if CurStep = ssDone then
begin
APPCONFIGPATH_Value := GetCommandLineParam('/APPCONFIGPATH');
end;
end;
答案 0 :(得分:0)
我在经过更多研究后发现,不需要等于'='符号。因此更新的[Run]部分应该看起来像
[Run]
Filename: {tmp}\v1700sp3.exe; Parameters: "/APPCONFIGPATH ""jjj"""; Flags: skipifdoesntexist