UninstallRun 中的检查参数功能无法正常工作

Check parameter function in UninstallRun does not work correctly

我想从 [UninstallRun] 部分中的 [Code] 部分获取参数。安装 时,我在调试输出 中得到了 "not found"。安装时我没有调用 CheckGetFile()...卸载时也没有调用 GetFilePath()CheckGetFile()..为什么?
这是我的脚本

[Code]
Var
  Check: Boolean;

function GetFilePath(Default: String): String;
begin
  log('GetFilePath()');
  Check := false;
  Result := '';
  { do something }
  if (Found) then
  begin
    Check := true;
    Result := TargetPath;
  end;
end;

function CheckGetFile: boolean;
begin
  if (Check) then
    begin
      log('Found File');
      Result := true;
    end;
  if (not Check) then
    begin
      log('not found');
      Result := false;
    end;
end;

[UninstallRun]
Filename: "{app}\MyApp.exe"; Parameters: "{code:GetFilePath}"; Check: CheckGetFile();

更新

[Code]
Var
  TargetPath: String;

function GetFilePath(): Boolean;
begin
  Result := false;
  { do something }
  if (Found) then
  begin
    TargetPath := 'C:\Windows\xxx';
    Result := true;
  end;
end;

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
  ResultCode : Integer;    
begin
  if CurUninstallStep = usUninstall then
  begin
    if (GetFilePath) then
    begin
      Exec(ExpandConstant('{app}\MyApp.exe'), '/q /u' + TargetPath, '',
           SW_SHOW, ewWaitUntilTerminated, ResultCode);  
    end;
  end;
end;

Check parameter 以安装时间计算。您不能使用它来检查卸载时文件是否存在。

为此你必须使用 [Code]:

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
  ResultCode : Integer;    
begin
  if CurUninstallStep = usUninstall then
  begin
    if Check then
    begin
      Exec(ExpandConstant('{app}\MyApp.exe'), '', '',
           SW_SHOW, ewWaitUntilTerminated, ResultCode);  
    end;
  end;
end;