WM_POWERBROADCAST is not sent is most cases?

2 weeks ago 16
ARTICLE AD BOX

I have a native Win32 application with a WndProc() that handles WM_POWERBROADCAST like this:

case WM_POWERBROADCAST: switch (wParam) { case PBT_APMPOWERSTATUSCHANGE: Trace("AC/DC change"); break; case PBT_APMRESUMEAUTOMATIC: Trace("Resume from sleep"); break; case PBT_APMRESUMESUSPEND: Trace("Resume from sleep by user"); break; case PBT_APMSUSPEND: Trace("Will go to sleep"); break; case PBT_POWERSETTINGCHANGE: Trace("Power setting change"); break; default: Trace("Unknown"); break; } return TRUE;

What to do, to make Windows 11 send all PBT_ messages?

Currently, I experience the following:

PBT_APMPOWERSTATUSCHANGE: This is sent when the power chord is plugged/unplugged from the laptop. PBT_APMRESUMEAUTOMATIC: This is not sent when the laptop wakes up from sleep due to a keypress. PBT_APMRESUMESUSPEND: This is not sent when the laptop wakes up from sleep due to a keypress. PBT_APMSUSPEND: This is not sent when the laptop goes to sleep. PBT_POWERSETTINGCHANGE: This is sent, if I register for it. I haven't seen the default branch executing.

So, the question is about the middle three.

Read Entire Article