3

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;
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Kushal
  • 605
  • 8
  • 29

1 Answers1

5

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;
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • 1
    @Kushal, this will fail on systems with localized folder names. Anyway, that you need to access virtual store folders indicates that you were writing into folders where you have not sufficient access rights (it's been the UAC virtualization that stored your stuff there when you were trying to write into program files). To resolve the problem stop writing into program files folders from your (non-elevated) application and use folders intended for storing user data, e.g. application data. – TLama Jul 03 '15 at 11:57
  • @TLama I am sorry i made a mistake.Please look into [this question](http://stackoverflow.com/questions/31206772/what-is-the-write-constant). – Kushal Jul 03 '15 at 12:25
  • Cannot you change your app. yet ? I bet there is no constant for the virtual store folders (most probably because you are not supposed to access them). – TLama Jul 03 '15 at 12:30