Poweroff / shell

G

Guest

Hi,
My Winxp embedded image that does NOT run Explorer.exe is not responding to
the power-off as it should. Am I correct in assuming that Explorer.exe
responds to the WM_POWERBROADCAST message, by shutting down the system ?

Now the system powers down "hard" (suddenly) after keeping the powerbutton
pressed 4 sec, without shutting dowbn nicely. When explorer.exe is running it
shuts down nicely. I need to add this behaviour to my app.

Any tips ?
Greetings,
Rob.
 
K

KM

Rob,

IIRC, it was not the Explorer but Winlogon that handled that broadcast and called to ExitWindow[Ex] API.
An old version of Minlogon was handling that message correctly as well, however that functionality got broken (or excluded) in newer
version.

You can verify if the above is true by reading lots of related threads in this NG archive.

Anyway, if you are running your own application as the shell you can always "fix" the behavior by providing your own handler for the
WM_POWERBROADCAST message. Basically if you catch the message by your window or thread proc, you should call a shutting the system
down API such as InitiateSystemShutdown, ExitWindowsEx, NTShutdownSystem (the fastest shutdown but not graceful), etc. Make sure
your app is granted SE_SHUTDOWN_NAME privilege first.
Or you can just execute command such as "xpepm.exe -shutdown" (Power Management Application component) or "fba -shutdown" or
"shutdown.exe -s -t 00 -f" if you prefer.

Some more info and ways how to intercept the power management events you can find in this thread:
http://groups.google.com/group/micr...mbedded/browse_thread/thread/0d300155d7c44bbe
 
G

Guest

Hi,
Thanks for the reply.
The shutdown is not the problem, lots of samples on inet about that....

So If I understand correctly, I should indeed receive a WM_POWERBROADCAST
message when the poweroff button is (shortly) pressed. The docu on this
subject is a bit vague about this.
If this is true, catching this msg , and shutting down should do the trick.

On inet I read :
"When Windows is about to shut down, it sends a WM_QueryEndSession to all
open applications."
Is this a more general msg ? also sent when ALT-F4 is pressed ?

Greetings,
Rob.









KM said:
Rob,

IIRC, it was not the Explorer but Winlogon that handled that broadcast and called to ExitWindow[Ex] API.
An old version of Minlogon was handling that message correctly as well, however that functionality got broken (or excluded) in newer
version.

You can verify if the above is true by reading lots of related threads in this NG archive.

Anyway, if you are running your own application as the shell you can always "fix" the behavior by providing your own handler for the
WM_POWERBROADCAST message. Basically if you catch the message by your window or thread proc, you should call a shutting the system
down API such as InitiateSystemShutdown, ExitWindowsEx, NTShutdownSystem (the fastest shutdown but not graceful), etc. Make sure
your app is granted SE_SHUTDOWN_NAME privilege first.
Or you can just execute command such as "xpepm.exe -shutdown" (Power Management Application component) or "fba -shutdown" or
"shutdown.exe -s -t 00 -f" if you prefer.

Some more info and ways how to intercept the power management events you can find in this thread:
http://groups.google.com/group/micr...mbedded/browse_thread/thread/0d300155d7c44bbe

--
=========
Regards,
KM
Hi,
My Winxp embedded image that does NOT run Explorer.exe is not responding to
the power-off as it should. Am I correct in assuming that Explorer.exe
responds to the WM_POWERBROADCAST message, by shutting down the system ?

Now the system powers down "hard" (suddenly) after keeping the powerbutton
pressed 4 sec, without shutting dowbn nicely. When explorer.exe is running it
shuts down nicely. I need to add this behaviour to my app.

Any tips ?
Greetings,
Rob.
 
K

KM

Rob,
So If I understand correctly, I should indeed receive a WM_POWERBROADCAST
message when the poweroff button is (shortly) pressed. The docu on this
subject is a bit vague about this.
If this is true, catching this msg , and shutting down should do the trick.

As I mentioned, this depends on what Logon componetn you endded up having in your image.
This works fine with WinLogon and only an old version of Minlogon.

In either case, just test it within your own application code running on the image. Try to capture the WM_POWERBROADCAST message.
On inet I read :
"When Windows is about to shut down, it sends a WM_QueryEndSession to all
open applications."
Is this a more general msg ?

Did you have a chance to read through the thread I sent you the link to in the previous post? The WM_QUERYENDSESSION was discussed
there.

Briefly, ExitWindowsEx sends out the WM_QUERYENDSESSION.
WM_POWERBROADCAST is being sent out (broadcasted) by the power management kernel rountine.

If Winlogon used, the sequence of the messages should be simple - WM_POWERBROADCAST is sent out when the power button pressed, some
code in Winlogon (this is a rough guess, of course) gets the broadcast and calls out the ExitWindowsEx API. The ExitWindowsEx will
send out WM_QUERYENDSESSION to all apps running, wait for responses and, if accepted, gracefully shutdown the system (well,
technically there is a bit more events such as WM_ENDSESSION, etc but I simplified the sequence).
also sent when ALT-F4 is pressed ?

ALT-F4? What do you mean? ALT-F4 is just closing-app event (when processed is translated to WM_CLOSE).

--
=========
Regards,
KM

KM said:
Rob,

IIRC, it was not the Explorer but Winlogon that handled that broadcast and called to ExitWindow[Ex] API.
An old version of Minlogon was handling that message correctly as well, however that functionality got broken (or excluded) in
newer
version.

You can verify if the above is true by reading lots of related threads in this NG archive.

Anyway, if you are running your own application as the shell you can always "fix" the behavior by providing your own handler for
the
WM_POWERBROADCAST message. Basically if you catch the message by your window or thread proc, you should call a shutting the
system
down API such as InitiateSystemShutdown, ExitWindowsEx, NTShutdownSystem (the fastest shutdown but not graceful), etc. Make sure
your app is granted SE_SHUTDOWN_NAME privilege first.
Or you can just execute command such as "xpepm.exe -shutdown" (Power Management Application component) or "fba -shutdown" or
"shutdown.exe -s -t 00 -f" if you prefer.

Some more info and ways how to intercept the power management events you can find in this thread:
http://groups.google.com/group/micr...mbedded/browse_thread/thread/0d300155d7c44bbe

--
=========
Regards,
KM
Hi,
My Winxp embedded image that does NOT run Explorer.exe is not responding to
the power-off as it should. Am I correct in assuming that Explorer.exe
responds to the WM_POWERBROADCAST message, by shutting down the system ?

Now the system powers down "hard" (suddenly) after keeping the powerbutton
pressed 4 sec, without shutting dowbn nicely. When explorer.exe is running it
shuts down nicely. I need to add this behaviour to my app.

Any tips ?
Greetings,
Rob.
 
G

Guest

Very clear, thanks again.....

Greetings,
Rob.



KM said:
Rob,
So If I understand correctly, I should indeed receive a WM_POWERBROADCAST
message when the poweroff button is (shortly) pressed. The docu on this
subject is a bit vague about this.
If this is true, catching this msg , and shutting down should do the trick.

As I mentioned, this depends on what Logon componetn you endded up having in your image.
This works fine with WinLogon and only an old version of Minlogon.

In either case, just test it within your own application code running on the image. Try to capture the WM_POWERBROADCAST message.
On inet I read :
"When Windows is about to shut down, it sends a WM_QueryEndSession to all
open applications."
Is this a more general msg ?

Did you have a chance to read through the thread I sent you the link to in the previous post? The WM_QUERYENDSESSION was discussed
there.

Briefly, ExitWindowsEx sends out the WM_QUERYENDSESSION.
WM_POWERBROADCAST is being sent out (broadcasted) by the power management kernel rountine.

If Winlogon used, the sequence of the messages should be simple - WM_POWERBROADCAST is sent out when the power button pressed, some
code in Winlogon (this is a rough guess, of course) gets the broadcast and calls out the ExitWindowsEx API. The ExitWindowsEx will
send out WM_QUERYENDSESSION to all apps running, wait for responses and, if accepted, gracefully shutdown the system (well,
technically there is a bit more events such as WM_ENDSESSION, etc but I simplified the sequence).
also sent when ALT-F4 is pressed ?

ALT-F4? What do you mean? ALT-F4 is just closing-app event (when processed is translated to WM_CLOSE).

--
=========
Regards,
KM

KM said:
Rob,

IIRC, it was not the Explorer but Winlogon that handled that broadcast and called to ExitWindow[Ex] API.
An old version of Minlogon was handling that message correctly as well, however that functionality got broken (or excluded) in
newer
version.

You can verify if the above is true by reading lots of related threads in this NG archive.

Anyway, if you are running your own application as the shell you can always "fix" the behavior by providing your own handler for
the
WM_POWERBROADCAST message. Basically if you catch the message by your window or thread proc, you should call a shutting the
system
down API such as InitiateSystemShutdown, ExitWindowsEx, NTShutdownSystem (the fastest shutdown but not graceful), etc. Make sure
your app is granted SE_SHUTDOWN_NAME privilege first.
Or you can just execute command such as "xpepm.exe -shutdown" (Power Management Application component) or "fba -shutdown" or
"shutdown.exe -s -t 00 -f" if you prefer.

Some more info and ways how to intercept the power management events you can find in this thread:
http://groups.google.com/group/micr...mbedded/browse_thread/thread/0d300155d7c44bbe

--
=========
Regards,
KM

Hi,
My Winxp embedded image that does NOT run Explorer.exe is not responding to
the power-off as it should. Am I correct in assuming that Explorer.exe
responds to the WM_POWERBROADCAST message, by shutting down the system ?

Now the system powers down "hard" (suddenly) after keeping the powerbutton
pressed 4 sec, without shutting dowbn nicely. When explorer.exe is running it
shuts down nicely. I need to add this behaviour to my app.

Any tips ?
Greetings,
Rob.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top