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 )
{
fRegisterSuspendResumeNotification(hWnd,DEVICE_NOTIFY_WINDOW_HANDLE);
}
}
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.
Homepage: onemanmmo.com email:one at onemanmmo dot com
typedef WINUSERAPI PVOID (WINAPI *REGISTERSUSPENDRESUMENOTIFICATION)(HANDLE hRecipient, DWORD Flags);