How to terminate your Delphi application before it starts

How to terminate your Delphi application before it starts

It sounds like a contradiction: Why would you start you application and terminate it right away? Well, sometimes we can only “really” launch our main form if certain requirements are met.

  • Does my configuration file exist?
  • Can I connect to the database?
  • Do other data files exist?
  • Do my image resources exist?
  • Is the hardware sufficient?

In all of these cases you might want to display an error message but not launch your application as a consequence. With Delphi VCL applications, it may seem simple at first. However, there is some housekeeping required in order to stop execution correctly.

The latest episode of “How it Works With Holger” gives you all the essential info you need.

Tags: , ,
8 comments on “How to terminate your Delphi application before it starts
  1. Martin Pelletier says:


    Question, do we lose the visual binding of datasource with components when not using global variables?

    • Holger Flick says:

      As Marco Cantu recommends removing them in all his recent books, I’d assume it will still work.

  2. Fronzel Neekburm says:

    I appreciate the work you put into this, but do you have a written version of this planned? I don’t feel comfortable watching a 12 minute video when the same amount of information can probably be read in 3 minutes.

    • I second that. Videos are a horribly time consuming source for information.

      • Holger Flick says:

        You are sadly in the small minority. Whenever I produced written information, I have been asked to produce a video instead. Even some feedback to my books has been that I should produce video tutorials and courses instead – which I am doing as well now.

        Like you, I love books and written content, but it seems it is no longer what the majority is asking for.

        As my time is limited, I have to balance between all media and this is one of the videos. Honestly, I was planning to create a composition of all HIW as a book version, but initial polls in a small crowd of developers yielded almost no interest as the videos were preferred.

    • Holger Flick says:

      Please see my reply to Thomas. I try to balance content between video and written content. However, whenever I release written content, I am being asked to produce a video instead. This is actually the first time somebody is asking for written content instead.

      • Fronzel Neekburm says:

        Thank you for taking the time to reply.
        I will bookmark it and hopefully find time to watch it.

    • I agree 100%.
      Videos are great for some things.
      But when you want to learn something quickly, they’re very frustrating.