Twitter  YouTube  E-Mail  RSS
The One Man MMO Project
The story of a lone developer's quest to build an online world :: MMO programming, design, and industry commentary
By Robert Basler on 2021-02-01 21:13:28
Homepage: email:one at onemanmmo dot com

WM_POWERBROADCAST mysteriously not working anymore in your app? Here's how you fix it.

Windows now has a thing called Modern Standby. The big problem with Modern Standby is that mysteriously Windows doesn't call WM_POWERBROADCAST anymore. To fix this, you now need to tell Windows you want power notifications. If you're running a new Windows SDK, just use RegisterSuspendResumeNotification and you're done. If you're not...

Call this little function from your WM_CREATE handler:

void EnableModernStandbyPowerNotifications( HWND hWnd )
// This API is only supported on Windows 8+ but is required to enable WM_POWERBROADCAST for systems with Modern Standby.
HMODULE userModule = LoadLibrary( TEXT( "User32.dll" ) );
REGISTERSUSPENDRESUMENOTIFICATION fRegisterSuspendResumeNotification = (REGISTERSUSPENDRESUMENOTIFICATION)GetProcAddress( userModule, "RegisterSuspendResumeNotification" );
if( fRegisterSuspendResumeNotification != NULL )

By Robert Basler on 2021-02-20 22:45:14
Homepage: email:one at onemanmmo dot com
You'll also need this:


New Comment

Cookie Warning

We were unable to retrieve our cookie from your web browser. If pressing F5 once to reload this page does not get rid of this message, please read this to learn more.

You will not be able to post until you resolve this problem.

Comment (You can use HTML, but please double-check web link URLs and HTML tags!)
Your Name
Homepage (optional, don't include http://)
Email (optional, but automatically spam protected so please do)
What color is the ocean? (What's this?)

  Admin Log In

[Home] [Blog] [Video] [Shop] [Press Kit] [About]
Terms Of Use & Privacy Policy