🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #2373

HELP: My app closes, but cancels Windows shutdown?

#2373
From: A Nonymous
Date: Thu, 08 Mar 2007 20:12
28 lines
2039 bytes
I have an application that used to shutdown gracefully if it was running 
when Windows shutdown.  Now I noticed that my application shuts down, but 
it also seems to cancel the Windows shutdown.

I trap/handle the WM_QUERYENDSESSION and WM_ENDSESSION messages to save my 
files and close.  I set the Msg.Result = 1 (ok to shutdown) in each handler 
so Windows should continue to shutdown.  It use to work...

I did some research and apparently any 3rd party component that is using 
AllocateHWnd and not calling DefaultWindowProc in the handler method can 
cause this problem. In that case the handler method is answering 0 to 
WM_QUERYENDSESSION which tells Windows to cancel the shutdown. 

This is a BIG application and I use a lot of components. I created a new 
project and have been adding components one at a time to see what kills the 
shutdown.  With an almost 5 minute reboot cycle this is EXTREMELY time 
consuming. There must be a better way?

Does anyone know any way of "tracing" a message so I can see where 
Msg.Result is being set incorrectly?

I also created a test application that sends the WM_QUERYENDSESSION and 
WM_ENDSESSION messages to my app in an attempt to "fake" the shutdown, but 
it seems to report that my app is responding properly.

Something is going wrong but I am having trouble finding it.

Can anyone help?
Technical Details
Message-ID: <Xns98ED90968E734anonymoushotmailcom@207.105.83.66>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,346f60f70c29a156,start
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: HELP: My app closes, but cancels Windows shutdown?
From: A Nonymous <anonymous@hotmail.com>
Message-ID: <Xns98ED90968E734anonymoushotmailcom@207.105.83.66>
User-Agent: Xnews/5.04.25
NNTP-Posting-Host: 74.254.162.162
Date: 8 Mar 2007 12:12:17 -0800
X-Trace: newsgroups.borland.com 1173384737 74.254.162.162 (8 Mar 2007 12:12:17 -0800)
Lines: 28
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail