Article View: borland.public.cppbuilder.nativeapi
Article #15765Re: WM_ENDSESSION + Win2k/WinXP
From: Eugene Mayevski
Date: Wed, 18 Jun 2003 20:02
Date: Wed, 18 Jun 2003 20:02
29 lines
2599 bytes
2599 bytes
Frank Gruber wrote: > It is getting even better. As shutdown is difficult to debug I put a fopen, > sprintf, fclose > sequence after every action I perform in the event handler to find out where > the > handler is getting interrupted. With these lines inside the message handler > it is no longer > interrupted by Windows. If I remove these lines the problem comes back. > IMHO the whole Windows shutdown process was allways full of quirks, badly > designed > or at least badly dokumented. Just my 2 cents. You just need to read MSDN. In some topic (don't have MSDN now) there's a statement saying something like this: "After this message is sent, any API operation can fail with ERROR_SHUTDOWN_IN_PROGRESS error". And this is what happens. Actually, you can't trust OS even after WM_QUERYENDSESSION. So all shutdown actions you want to do should be done in responce to WM_QUERYENDSESSION. The best thing is to close the application by posting WM_CLOSE to main form when you receive WM_QUERYENDSESSION and not wait until system kills your application. In ElPack (http://www.eldos.org/elpack/elpack.html) we have a special unit, whose only job is to track WM_QUERYENDSESSION and gracefully close the application. This unit is also present in my article on Delphi3000. -- Eugene Mayevski Flexible cross-platform information exchange framework http://www.msgconnect.com/
Technical Details
Message-ID:
<3ef0c5ce@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3ef08c31$1@newsgroups.borland.com> <3ef09b02$1@newsgroups.borland.com> <3ef0a332@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,9e00bf1ef85252e4 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-06-18 13:08:32 PST Date: Wed, 18 Jun 2003 23:02:13 +0300 From: Eugene Mayevski <mayevski@eldos.org> Reply-To: mayevski@eldos.org User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, uk, en, ru MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: WM_ENDSESSION + Win2k/WinXP References: <3ef08c31$1@newsgroups.borland.com> <3ef09b02$1@newsgroups.borland.com> <3ef0a332@newsgroups.borland.com> In-Reply-To: <3ef0a332@newsgroups.borland.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 212.9.249.152 Message-ID: <3ef0c5ce@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1055966670 212.9.249.152 (18 Jun 2003 13:04:30 -0700) Lines: 30 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail