InnoSetup Uninstall Ask Message - Pascal Encoding

I created an installer for some of my games, and I want the uninstaller to ask me if I want to save the game files. Something like this: when I run uninstall.exe to ask me: "Do you want to save all saved games?" Yes or no. If I delete YES, my saved files remain and my program files are deleted, and if I delete NO, my program files inclusively save the files that need to be deleted. What is the PASCAL code for InnoSetup for this?

Many thanks!

+3
source share
2 answers

You can do something like:


; -- UninstallCodeExample1.iss --
;
; This script shows various things you can achieve using a [Code] section for Uninstall
[Setup]
AppName=My Program
AppVerName=My Program version 1.5
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
OutputDir=userdocs:Inno Setup Examples Output

[Files]
Source: "MyProg.exe"; DestDir: "{app}"
Source: "MyProg.chm"; DestDir: "{app}"
Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme

[Code]
function InitializeUninstall(): Boolean;
begin
  Result := MsgBox('InitializeUninstall:' #13#13 'Uninstall is initializing. Do you really want to start Uninstall?', mbConfirmation, MB_YESNO) = idYes;
  if Result = False then
    MsgBox('InitializeUninstall:' #13#13 'Ok, bye bye.', mbInformation, MB_OK);
end;

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
mRes : integer;
begin
  case CurUninstallStep of
    usUninstall:
      begin
        mRes := MsgBox('Do you want to remove all files?', mbConfirmation, MB_YESNO or MB_DEFBUTTON2)
        if mRes = IDYES then
          begin
             MsgBox ('Really remove the files', mbInformation, MB_OK)
             DeleteFile('path\filename.ext');
          End
        else
          MsgBox ('Don''t remove the game files', mbInformation, MB_OK);        
        // ...insert code to perform pre-uninstall tasks here...
      end;
  end;
end;

InnoSetup , . UninstallCodeExample.iss, InnoSetup.

, , . DeleteFile. DeleteFile , , [Files].

+8

, , " , % 1 ?" - , , ,

[Messages]
ConfirmUninstall=Are you really really sure you want to remove %1?

ref: http://www.jrsoftware.org/ishelp/index.php?topic=messagessection

+3

Source: https://habr.com/ru/post/1746992/


All Articles