G
Georges Berenger
Hi there!
Some of you may remember that I long lamented the fact that with SP1
(with no patches), when you pressed the power button, the system
wouldn't shutdown.
Much later, Slobodan helped: with a properly set up message filter and a
proper configuration, you actually got a PBT_APMQUERYSUSPEND message
that you could react on as you wanted. All was good.
But now, with SP2, things have been "fixed". Fixed so well that I have a
problem that happens both with SP2 & XP Pro. (I guess some will tell me
then that this issue should go to an other group. I'd reply that this
issue is particularly important when building appliances, if not only
with appliances, therefore, the issue is mostly an XPe issue).
I see two (main) ways to configure the action of the power button. One
is to set it to "PowerActionNone", the other is to set it to
"PowerActionShutdown".
When you set the action to "PowerActionNone", that's what you get:
nothing. I don't even know that the button was pressed.
When you set the action to "PowerActionShutdown", that's what you get: a
shutdown. Always. And that's the issue: I can't stop the shutdown.
Wether I return BROADCAST_QUERY_DENY or not in my message filter, the
shutdown happens.
What I really want to do is detect that the button has been pressed in
some way (I don't really care how), and then, show the user a dialog.
Depending on the user's action, I then request a shutdown or not.
SP1 used to send the PBT_APMQUERYSUSPEND, and then do nothing. Which
gave me a chance to do what I wanted. Now, I either get nothing or all,
and this is not what I need.
Does anyone know either:
- how to detect that the power button has been pressed without having a
shutdown sequence started
-or-
- how to cancel a shutdown sequence.
BTW: I have configured the power management with:
SYSTEM_POWER_POLICY policy;
::CallNtPowerInformation(SystemPowerPolicyAc, NULL, 0, &policy,
sizeof(policy);
policy.PowerButton.Action = PowerActionShutdown;
policy.PowerButton.Flags = POWER_ACTION_QUERY_ALLOWED |
POWER_ACTION_UI_ALLOWED;
policy.PowerButton.EventCode = POWER_USER_NOTIFY_BUTTON;
::CallNtPowerInformation(SystemPowerPolicyAc, &policy, sizeof(policy),
&policy, sizeof(policy));
(yes, that works: if I change PowerActionShutdown to PowerActionNone, I
do not get a shutdown anymore).
Any clue?
Thanks,
-georges
Some of you may remember that I long lamented the fact that with SP1
(with no patches), when you pressed the power button, the system
wouldn't shutdown.
Much later, Slobodan helped: with a properly set up message filter and a
proper configuration, you actually got a PBT_APMQUERYSUSPEND message
that you could react on as you wanted. All was good.
But now, with SP2, things have been "fixed". Fixed so well that I have a
problem that happens both with SP2 & XP Pro. (I guess some will tell me
then that this issue should go to an other group. I'd reply that this
issue is particularly important when building appliances, if not only
with appliances, therefore, the issue is mostly an XPe issue).
I see two (main) ways to configure the action of the power button. One
is to set it to "PowerActionNone", the other is to set it to
"PowerActionShutdown".
When you set the action to "PowerActionNone", that's what you get:
nothing. I don't even know that the button was pressed.
When you set the action to "PowerActionShutdown", that's what you get: a
shutdown. Always. And that's the issue: I can't stop the shutdown.
Wether I return BROADCAST_QUERY_DENY or not in my message filter, the
shutdown happens.
What I really want to do is detect that the button has been pressed in
some way (I don't really care how), and then, show the user a dialog.
Depending on the user's action, I then request a shutdown or not.
SP1 used to send the PBT_APMQUERYSUSPEND, and then do nothing. Which
gave me a chance to do what I wanted. Now, I either get nothing or all,
and this is not what I need.
Does anyone know either:
- how to detect that the power button has been pressed without having a
shutdown sequence started
-or-
- how to cancel a shutdown sequence.
BTW: I have configured the power management with:
SYSTEM_POWER_POLICY policy;
::CallNtPowerInformation(SystemPowerPolicyAc, NULL, 0, &policy,
sizeof(policy);
policy.PowerButton.Action = PowerActionShutdown;
policy.PowerButton.Flags = POWER_ACTION_QUERY_ALLOWED |
POWER_ACTION_UI_ALLOWED;
policy.PowerButton.EventCode = POWER_USER_NOTIFY_BUTTON;
::CallNtPowerInformation(SystemPowerPolicyAc, &policy, sizeof(policy),
&policy, sizeof(policy));
(yes, that works: if I change PowerActionShutdown to PowerActionNone, I
do not get a shutdown anymore).
Any clue?
Thanks,
-georges