Inno Setup 卸载程序中的脚本常量

Inno Setup Scripted Constants in uninstaller

在我的 Inno Setup 中,我调用了第二个可选安装程序。如果我的应用程序已卸载,我想卸载它。但如果我不想猜测或询问用户,我必须获得注册表项的卸载路径。

是否可以在卸载我的应用程序时获取此注册表项作为“卸载 运行”的脚本变量? 据我了解,“卸载 运行”是 unins000.dat 的一部分,它是在安装时完全生成的,所以没有办法吗?

要使用 [UninstallRun] 部分,您必须知道安装时的路径。由于所有部分中的常量都在安装时解析。

如果您不知道安装时的路径,您必须使用Pascal Script event function CurUninstallStepChanged. In the function, you can resolve the paths using Reg* support functions. Probably using RegQueryStringValue. Then you can execute the found binary using the Exec function

[Code]

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
  Path: string;
begin
  if CurUninstallStep = usUninstall then
  begin
    if RegQueryStringValue(..., ..., ..., Path) then
    begin
      Log(Format('Executing %s...', [Path]));
      Exec(Path, ...);
    end;
  end;
end;