KurayamiArai
KurayamiArai

Reputation: 311

Inno Setup: How to remove Abort from regserver error?

I was wondering, if there is a way to make the message box displayed, when occurs an error from regserver flag in Files section, to show only Retry and Ignore option, not the Abort one.

I know there's a flag noregerror. I don't want to not show the error. I want to show it, but with only two options.

Sometimes when the error is displayed while trying to register an OCX/DLL, when the user clicks in Retry, it works in the second time. If the user clicks in Cancel, the installer rollbacks everything, deleting the files from my update program.

Thanks.

Upvotes: 1

Views: 612

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202642

There's no way to customize those buttons.

But you can implement the registration in code using RegisterServer. Then you can handle errors any way you like. You can actually even retry the registration automatically, what you seem to actually want to do.

Though it's not easy to implement Retry/Ignore message box. The below code uses simple Yes/No.

[Files]
Source: "MyDll.dll"; DestDir: "{app}"; AfterInstall: RegServer

[Code]

procedure RegServer;
var
  FileName: string;
  Message: string;
  Retry: Boolean;
begin
  repeat
    Retry := False;
    FileName := ExpandConstant(CurrentFilename);
    try
      { First argument indicates if DLL is 64-bit }
      RegisterServer(False, FileName, True);
    except
      Message :=
        FileName + #13#10#13#10 +
        FmtMessage(SetupMessage(msgErrorRegisterServer), [AddPeriod(GetExceptionMessage)]) +
          #13#10#13#10 +
        'Do you want to retry registration? ' +
        'Click Yes to try again or No to proceed anyway (not recommended).';
      Retry := (MsgBox(Message, mbError, MB_YESNO) = IDYES);
    end;
  until (not Retry);
end;

Registration error

Upvotes: 1

Related Questions