🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: My app closes, but cancels Windows shutdown?

#2376
From: A Nonymous
Date: Thu, 08 Mar 2007 20:59
52 lines
2591 bytes
"Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> wrote in news:45f07307
@newsgroups.borland.com:

> 
> "A Nonymous" <anonymous@hotmail.com> wrote in message
> news:Xns98ED90968E734anonymoushotmailcom@207.105.83.66...
> 
>> 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...
> 
> According to the documentation, the return value for WM_ENDSESSION is
> 0, not 1.
> 
It doesn't appear to work that way.  You may not have seen my addendum 
when you posted this response, but take a look at it.

To simplify the problem I created a new application.  I created only a 
handlet for the WM_QUERYENDSESSION and WM_ENDSESSION messages.

void __fastcall TFormMain::wmQueryEndSession(TMessage& Message)
{
  Message.Result = 1;
  Application->Terminate();
}

void __fastcall TFormMain::wmEndSession(TMessage& Message)
{
  Message.Result = 1;
}

The app terminates and Windows restarts.

I changed the Message.Result to 0 (in both) and the application 
terminated but Windows did not restart.  This is the problem I am trying 
to resolve.

I used my "fake" shutdown app to send the shutdown messages to both 
versions of the test applcation and with Message.Result = 1, the app 
shuts down, I get a true response from the SnedMessage and both wParam 
and lParam are 0.

The same operation with Message.Result = 0, the app shuts down, I get a 
FALSE response from the SnedMessage and both wParam and lParam are still 
0.

On my real app, the app shuts down, I get a true response from the 
SnedMessage and both wParam and lParam are 0, BUT Windows does not 
restart.

There must be something else?  I just don't know how to find it.
Technical Details
Message-ID: <Xns98ED988E421A8anonymoushotmailcom@207.105.83.66>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <Xns98ED90968E734anonymoushotmailcom@207.105.83.66> <45f07307@newsgroups.borland.com>

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