Inno setup Inno卸载运行如何通过执行

Inno setup Inno卸载运行如何通过执行,inno-setup,Inno Setup,我的目标是在[UninstallRun]读取注册表项 问题是,如果Inno安装程序在安装过程中运行,那么函数GetRegistryVar在这里调用吗?卸载过程正在运行时应调用它。如果启动卸载过程,函数GetRegistryVar将不会在此处调用?只有CurUninstallStepChanged和PGetRegistryVal。所以我无法接收全局变量gStrPrnName [UninstallRun] Filename: "{#dInst64bitDir}\{#dUnInstDrvExeName

我的目标是在[UninstallRun]读取注册表项

问题是,如果Inno安装程序在安装过程中运行,那么函数GetRegistryVar在这里调用吗?卸载过程正在运行时应调用它。如果启动卸载过程,函数GetRegistryVar将不会在此处调用?只有CurUninstallStepChanged和PGetRegistryVal。所以我无法接收全局变量gStrPrnName

[UninstallRun]
Filename: "{#dInst64bitDir}\{#dUnInstDrvExeName}"; Parameters: "-f {code:GetGlobalRegistryVar}"; WorkingDir: "{#dInst64bitDir}"; Flags: runhidden runascurrentuser;

[Code]
var
  gStrPrnName: string;

function GetGlobalRegistryVar(Value: string): string;
begin
  Result := gStrPrnName;
end;

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
  begin
    case CurUninstallStep of
    usUninstall:
      begin
      // ...insert code to perform pre-uninstall tasks here...
      PGetRegistryVal(gStrPrnName);
      end;
    usPostUninstall:
      begin
      // ...insert code to perform post-uninstall tasks here...
      end;
  end;
end;


function PGetRegistryVal(Value: String): String;
var
  strPrnName: string;
  i: Integer;
begin

     for i:=0 to 2 do
   begin
      if RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\GetDevice_1', 'Name', strPrnName) then
        Result := strPrnName;
      if RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\GetDevice_2', 'Name', strPrnName) then
        Result := strPrnName;
     ...
   end;
end;
有人能解决这个问题吗


谢谢

这是因为当安装程序写入卸载日志时,[UninstallRun]部分参数会在安装时展开,此时您的全局变量为空。如果你需要注册的话。值在卸载时,您需要停止使用[UninstallRun]部分并运行该应用程序。从[Code]手动执行。对于那些认真对待安装脚本编写的人,我补充说,您应该避免使用类似于此脚本中的全局变量。