Strings Delphi

Use the Application.OnException event. Look in the help under "application
events" for details of how to create and attach an event handler to the
application variable.