2

I've a problem with WizardForm's, when I trying to uninstall the program I have this error:

Runtime Error:

Internal error: An attempt was made to access WizardForm before it has been created.

enter image description here

I need to create soft abort uninstallation process with loop (e.g. when application is running and user run the uninstall, program must check processes and if application is running, notify user and if user press the cancel button the program abort uninstallation), I've tried with ExitProcess(0); but it isn't gentle.

Code section:

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
  case CurUninstallStep of
    usUninstall:
    begin
      if MsgBox('Close the {#AppName}, before uninstallation.', mbConfirmation, MB_YESNO) = IDYES then
      begin
        { user clicked Yes }
      end
        else
      begin
        MsgBox('Error',mbError,MB_OK);
        CancelWithoutPrompt := true;
        { ExitProcess(0); }
        WizardForm.close;
      end
    end; 
  end;
end;
Community
  • 1
  • 1
Anatoly Feteleu
  • 111
  • 2
  • 10
  • Maertin Prikryl, the main problem is this error - An attempt was made to access WizardForm before it has been created. – Anatoly Feteleu Apr 28 '17 at 07:20
  • Martin Prikryl, I want to abort the uninstallation with aborting section, with window - "Abort Uninstallation. Installation canceled by user". I think this can be done with WizardForm. – Anatoly Feteleu Apr 28 '17 at 07:25

1 Answers1

3

Your approach to implementing your problem is wrong, see at the end.

Anyway, to address your immediate issue: The WizardForm is an installer form. It does not exist in an uninstaller. In the uninstaller, you have UninstallProgressForm. See documentation.

But you do not want to call UninstallProgressForm.Close. That's wrong for the reasons given below.


Inno Setup has a built-in mechanism to prevent an (un)installer from proceeding, while an application is running. The AppMutex directive.

Even if you want to build your own solution, use the InitializeUninstall event function, where you can exit the uninstaller easily and cleanly, by returning False. And you can, of course, display any message you like, before you exit. Just use MsgBox function.

All this is covered in my answer to Uninstall fails because program is running. How do I make Inno Setup check for running process prior to attempting delete?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992