If an application detects that it is not able to start because of "something" is missing (in my case a special app-specific font installed) and try to stop running the app by calling "Application.Terminate" in (any) ...FormCreate callback "TApplication.Run" will be still called and it execution will cause an exception.
I modified "TApplication.Run" by adding 3 lines, so it's now:
procedure TApplication.Run;
begin
if not Terminated then // <-- THIS IS ADDED
begin
if (FMainForm <> nil) and FShowMainForm then
begin
WidgetSet.AppSetupMainForm(FMainForm);
FMainForm.Show;
end;
WidgetSet.AppRun(@RunLoop);
end;
end;
The additional line solves the problem without modifing any project specific code. Here is a snippet of my app source (sorry for the german message text):
procedure TMainForm.FormCreate(Sender: TObject);
var
lStp: boolean;
begin
lStp := Screen.Fonts.IndexOf(TM_FontName) < 0;
try
if lStp then
ShowMsgDlg(CreateMessageDialog('Die benötigte Schriftart "' + TM_FontName +
'" ist nicht'#13#10'installiert: ' +
'Das Programm muss deshalb beendet werden',
mtCustom, [mbOK]))
else
begin
...
...
...
end;
finally
if lStp then
Application.Terminate();
end;
end;