Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SetUnhandledExceptionFilter

211 views
Skip to first unread message

Marius Oloeru

unread,
Apr 14, 2003, 7:26:20 AM4/14/03
to
Hi all

Does anyone know how to use this function (SetUnhandledExceptionFilter) in
Delphi ?
I try to use it but i dont succeeded.

More exactly : I try to override the default exception handler with my own,
but is seems like Delphi does not call this function when an error has
occured and is not included in an try..except statement. I have studied some
examples in VC++ and things are pretty clear about how to do this, but i did
not succeeded to make it work in Delphi.

PS : I dont want to use TApplication.OnException or
TApplicationEvents.OnException

Regards, Marius.


Nico Bendlin

unread,
Apr 14, 2003, 8:11:34 AM4/14/03
to
Marius Oloeru wrote:
> More exactly : I try to override the default exception handler with my own,
> but is seems like Delphi does not call this function when an error has
> occured and is not included in an try..except statement. I have studied some
> examples in VC++ and things are pretty clear about how to do this, but i did
> not succeeded to make it work in Delphi.

IIRC, Delphi uses Structured Exception Handling (SEH)
directly (via FS:[0]) and establishes an default
exception handler. See ErrorProc for more information.

- nico

ps: I recommend to NOT break the existing
exception handler chain by setting FS:[0]


Nico Bendlin

unread,
Apr 14, 2003, 9:14:55 AM4/14/03
to
Nico Bendlin wrote:
> IIRC, Delphi uses Structured Exception Handling (SEH)
> directly (via FS:[0]) and establishes an default
> exception handler. See ErrorProc for more information.

Whoops, should be ExceptProc instead of ErrorProc.

Marius Oloeru

unread,
Apr 14, 2003, 9:24:33 AM4/14/03
to
ExceptProc is not working either...

Regards, Marius.

madshi

unread,
Apr 14, 2003, 9:41:52 AM4/14/03
to
There is no "default exception handler". There is a chain of exception
handlers. Windows calls all exception handlers one by one, beginning
with the "youngest". As soon as one exception handler states that it
wants to handle (=resolve) the exception, it's gone and the remaining
handlers in the exception chain are not called anymore.

SetUnhandledExceptionFilter doesn't set the default exception handler,
it sets the lop level exception handler, which is a totally different
thing. This handler is only called, if no other handlers wants to handle
the exception.

The exception handler chain is internally built by the compiler. Each
try..except and try..finally statement temporarily adds a handler to the
exception chain.

Enough theory. What do you really want to achieve?

--
www.madshi.net
quality low level Delphi components
extended exception handling
API hooking, DLL injection
undocumented functionality

Marius Oloeru

unread,
Apr 14, 2003, 10:16:03 AM4/14/03
to
Well, the purpose of my questions is :
I want that if an error has occured in my application, the application
should call my exception handler. Why do i want that ?
Because i dont want to see any message boxes with all kind of messages on
the screen.
Instead i want to catch where the error has occured, how bad is the error,
etc... and then to save them and to have opportunity
to study them and then resolve.
But, whatever is going on, i want that the application keep moving on, even
if bad errors have been occured.

Regards, Marius.

madshi

unread,
Apr 14, 2003, 11:02:08 AM4/14/03
to
Please forgive me if I use this as a chance for advertising. But what
you want sounds like the perfect situation to use one of the existing
exception tracker components. E.g. look at mine, it's named "madExcept"
and it's even free for non-commercial usage. With it you can register a
little exception handler like this:

uses madExcept;

procedure MariusExceptionHandler(...; bugReport: string; ...);
begin
// here you can with the bug report whatever you like
handled := true;
end;

intialization
RegisterExceptionHandler(MariusExceptionHandler);
end.

The bug report contains a full stack trace of all running threads and
lots of more information like a module list and such stuff. If you use
an exception handler like the one shown above (and better additionally
uncheck the option "show exception box"), all exceptions will be handled
silently. Even the TApplication.ShowException and SysUtils.ShowException
methods are reverted to madExcept.

Here are links to the online documentation, to the direct download of
the latest (beta) version and to a little demo:

http://help.madshi.net/madExcept.htm
http://madshi.bei.t-online.de/madCollectionBeta.exe
http://madshi.net/ExcCatch.zip

Marius Oloeru

unread,
Apr 14, 2003, 11:23:35 AM4/14/03
to
Ok, thank's. I will try it.

Regards, Marius.

0 new messages