Inno-Setup – Innosetup Uninstall Ask News – Pascal Coding

I created an installer for some of my games, and I want the uninstaller to be able to ask me if I want to save my game files.
Things like this: when I execute uninstall. The exe asked me’Do you want to keep all saved games? ‘Yes or not. If I click YES, my save file will remain and my program file will be uninstalled. If I click NO, my program file will be uninstalled if it contains the saved file.
What does the PASCAL code of InnoSetup do? of?

Thank you very much!

You can do this:

< pre>; – 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 CurUninstallStep Changed(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;

You may want to use the latest version InnoSetup, just like I tested. The above example is based on the UninstallCodeExample.iss that comes with the InnoSetup compiler.

I added a line of code to illustrate how to delete the file. It calls the DeleteFile function. You need to Add a DeleteFile for each file to be deleted, which is not in the [Files] section.

I created an installer for some of my games, and I want to uninstall the program Be able to ask me if I want to save my game files.
Something like this: When I execute uninstall.exe and ask me’Do you want to keep all saved games? ‘Yes or not. If I click YES, my save file will remain and my program file will be uninstalled. If I click NO, my program file will be uninstalled if it contains the saved file.
What does the PASCAL code of InnoSetup do? of?

Thank you very much!

You can do this:

; - 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< br />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);
varmRes: 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;

You may want to use the latest version of InnoSetup, as I tested. The above example is based on UninstallCodeExample.iss that comes with the InnoSetup compiler.

I added a line of code to illustrate how to delete a file. It calls the DeleteFile function. You need to add a DeleteFile for each file that you want to delete when uninstalling, and the file is not there. In the [Files] section.

Leave a Comment

Your email address will not be published.