user1706975
user1706975

Reputation: 325

Inno Setup - Uninstall Registry Removal Option

The program I'm building an installer for uses registry entries to store user settings. Right now I have it set to delete said registry files when the program is uninstalled, but I would like the ability to give users an option to either keep or delete the registry files upon uninstall.

I'm not the best scripter/programmer, so the simpler the answer, the better.

My registry/uninstall currently looks like this.

    [Registry]
    Root: HKCU; Subkey: "Software\FFSPLIT Overlay Filter"; Flags: uninsdeletekey


    [UninstallDelete]  
    Type: filesandordirs; Name: "{app}\ffmpeg"
    Type: filesandordirs; Name: "{app}\OverlayData"
    Type: files; Name: "{app}\AForge.Controls.dll"
    Type: files; Name: "{app}\AForge.Imaging.dll"
    Type: files; Name: "{app}\AForge.Video.DirectShow.dll"
    Type: files; Name: "{app}\AForge.Video.dll"
    Type: files; Name: "{app}\AudioFilter.ax"
    Type: files; Name: "{app}\default.cfg"
    Type: files; Name: "{app}\DirectShowLib-2005.dll"
    Type: files; Name: "{app}\ffmpeg.exe"
    Type: files; Name: "{app}\FFSplit Overlay Filter.ax"
    Type: files; Name: "{app}\FFsplit.exe"
    Type: files; Name: "{app}\FFSplitOverlayManager.exe"
    Type: files; Name: "{app}\librtmp.dll"
    Type: files; Name: "{app}\msvcp100d.dll"
    Type: files; Name: "{app}\msvcr100d.dll"
    Type: files; Name: "{app}\NAudio.dll"
    Type: files; Name: "{app}\RegisterFilter.bat"
    Type: files; Name: "{app}\setting.cfg"
    Type: files; Name: "{app}\UNRegisterFilter.bat"
    Type: files; Name: "{app}\wavbuffer"
    Type: files; Name: "{app}\Micfilter.ax"

Upvotes: 13

Views: 16044

Answers (1)

TLama
TLama

Reputation: 76733

InnoSetup doesn't have any conditional uninstall check parameter, so you have to do this by yourself. So you need to remove the uninsdeletekey flag which would delete the registry key automatically and at the end of the uninstallation process you can ask user if he wants to delete that key (in some meaningful message way) and delete the key manually. The following script does this at the post uninstall step, what is the time when the application was successfully uninstalled. You can follow the commented version:

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program

#define FilterRegKey "Software\FFSPLIT Overlay Filter"

[Registry]
Root: HKCU; Subkey: "{#FilterRegKey}"

[Code]
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
  if CurUninstallStep = usPostUninstall then
  begin
    if RegKeyExists(HKEY_CURRENT_USER, '{#FilterRegKey}') then
      if MsgBox('Do you want to delete the overlay filter registry key ?',
        mbConfirmation, MB_YESNO) = IDYES
      then
        RegDeleteKeyIncludingSubkeys(HKEY_CURRENT_USER, '{#FilterRegKey}');
  end;
end;

Upvotes: 28

Related Questions