Exceptions in DLLs

This section discusses issues regarding DLLs and Win32 exceptions.

Capturing Exceptions in 16-Bit Delphi

Back in the 16-bit days with Delphi 1, Delphi exceptions were language specific. Therefore, if exceptions were raised in a DLL, you were required to capture the exception before it escaped from the DLL so that it wouldn't creep up the calling modules stack, causing it to crash. You had to wrap every DLL entry point with an exception handler, like this:

procedure SomeDLLProc;
begin
  try
    { Do your stuff }
  except
     on Exception do
        { Don't let it get away, handle it and don't re-raise it }
  end;
end;

This is no longer the case as of Delphi 2. Delphi 6 exceptions map themselves to Win32 exceptions. Exceptions raised in DLLs are ...

Get Borland® Delphi™ 6 Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.