From: Limonada on
Hi All,

I need to disable the power button in Windows XP and I'm having a
really hard time understanding the Power Management API's. I tried to
use the following code:

---------------------------------------------------------------------------------
BOOLEAN bResult;
UINT i;
GLOBAL_POWER_POLICY GlobalPowerPolicy;

bResult = FALSE;
bResult = ReadGlobalPwrPolicy(&GlobalPowerPolicy);
if (bResult) {
GlobalPowerPolicy.user.PowerButtonAc.Action = PowerActionNone;
GlobalPowerPolicy.user.PowerButtonAc.EventCode = 0;
bResult = WriteGlobalPwrPolicy(&GlobalPowerPolicy);
if (bResult) {
bResult = GetActivePwrScheme(&i);
if (bResult) {
bResult = SetActivePwrScheme(i, &GlobalPowerPolicy, NULL);
}
}
}
---------------------------------------------------------------------------------

While playing with the Power Management API at some point I managed to
make this work although I can't reproduce that anymore. However, it
still needed a reboot. Although the API's were executed successfully,
if I immediately looked into the Power options control panel in the
"Advanced" tab I could see no change.
I am sure there must be a way to do this since it is done by the Power
Options control panel. I would really like to know how I can achieve
this using the Windows XP API (and without a reboot).

Many thanks,
Adrian

From: alfred on
Limonada wrote:
> Hi All,
>
> I need to disable the power button in Windows XP

Not kernel question at all.
Post on ui group.