Article View: borland.public.cppbuilder.nativeapi
Article #8772Detect Windows shutdown or Log Off
From: Adelino Rocha
Date: Thu, 23 Sep 2004 23:40
Date: Thu, 23 Sep 2004 23:40
43 lines
2033 bytes
2033 bytes
Hi,
I have an application that needs to record some values on a file
when application is normally closed but also when when closed by Windows
before shutting down or logging off.
I have been trying to trace and handle on TApplication OnMessage
event more than 1 windows messages related with shutting down event but
with no success:
Something like:
void __fastcall TFrmMain::AppMessage(tagMSG &Msg, bool &Handled)
{
if ((Msg.message == WM_QUERYENDSESSION) || (Msg.message ==
WM_ENDSESSION)
|| (Msg.message == WM_CLOSE))
{
if (FrmMain->ConfigData->Values["AutoLogOff"] == "1")
BtnOutClick(FrmMain);
// Guardamos as configura��es:
SaveConfigs();
// e entregamos o processamento ao Windows (aplica��o pode
terminar):
Handled = false;
}
}
I didin't forget to register the OnMessage Event routine when
application starts:
void __fastcall TFrmMain::FormCreate(TObject *Sender)
{
Application->OnMessage = AppMessage;
....
}
...but this seems not to work.
Does anybody knows why ?
Is there any other more effective method to do this ?
Thanks,
Adelino.
Technical Details
Message-ID:
<41535EEC.FC350D2A@mail.telepac.pt>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,f62d70a312897be3,start X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII Message-ID: <41535EEC.FC350D2A@mail.telepac.pt> Date: Fri, 24 Sep 2004 00:40:30 +0100 From: Adelino Rocha <aderocha@mail.telepac.pt> X-Mailer: Mozilla 4.78 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Detect Windows shutdown or Log Off Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit NNTP-Posting-Host: 213.13.99.136 X-Trace: newsgroups.borland.com 1095982016 213.13.99.136 (23 Sep 2004 16:26:56 -0700) Lines: 44 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail