[阅读: 450] 2007-06-27 10:39:25
When you have a delphi application running, and you are shutting down
windows, (don't close your app first), NONE of your destructors are
called!!!!
The problem seems to be that when you close down Windows, it will first
send a WM_QueryEndSession message to all running top-level windows. This
is handled and processed correctly by the TForm object in VCL.
Then assuming that all applications indicated that it was ok to close down,
Windows will send WM_EndSession messages to all windows. This message is
not handled by VCL. The application is simply brought down with a bang.
No windows are closed, no destructor called and no exit procedures called.
The solution is to handle the WM_EndSession message yourself. There are
several ways of handling messages in Delphi, but the only reliable way
of handling the WM_ENDSESSION is to use the HookWindow method of
Application.