How to check 64/32-bit in Inno setup

2020-08-01 08:05发布

I want to go inside a folder. It will be Program Files (x86) if 64-bit Program Files if 32-bit. How to do that in Inno setup.

This is the code I tried (but no luck):

procedure CurUninstallStepChanged (CurUninstallStep: TUninstallStep);
var
  mres : integer;
begin
  case CurUninstallStep of
    usPostUninstall:
      begin
        mres := MsgBox('Do you want to delete saved games?', mbConfirmation, MB_YESNO or MB_DEFBUTTON2)
        if mres = IDYES then
          if ProcessorArchitecture = paIA64 then
            begin
               if IsWin64 then
                DelTree(ExpandConstant('{userappdata}\Local\VirtualStore\Program Files (x86)\MY PROJECT'), True, True, True);
          else
                DelTree(ExpandConstant('{userappdata}\Local\VirtualStore\Program Files\MY PROJECT'), True, True, True);
          end;
      end;
  end;
end;

1条回答
别忘想泡老子
2楼-- · 2020-08-01 08:56

Your begin's and end's do not match. And there should be no semicolon before else.

And you should not care about processor architecture (ProcessorArchitecture), but only whether the Windows is 64-bit (IsWin64).

procedure CurUninstallStepChanged (CurUninstallStep: TUninstallStep);
var
  mres : integer;
begin
  case CurUninstallStep of
    usPostUninstall:
      begin
        mres := MsgBox('Do you want to delete saved games?', mbConfirmation, MB_YESNO or MB_DEFBUTTON2)
        if mres = IDYES then
        begin
          if IsWin64 then
            DelTree(ExpandConstant('{userappdata}\Local\VirtualStore\Program Files (x86)\MY PROJECT'), True, True, True)
          else
            DelTree(ExpandConstant('{userappdata}\Local\VirtualStore\Program Files\MY PROJECT'), True, True, True);
        end;
      end;
  end;
end;
查看更多
登录 后发表回答