question

NingnanNN1Feng-4520 avatar image
0 Votes"
NingnanNN1Feng-4520 asked mkdr-6590 edited

Cannot receive WM_POWERBROADCAST message on Win10 2004

I write an application with C++, , I regist the system message notification already.when it runs on win10 1809, it can receive WM_POWERBROADCAST message, but when it runs on Win10 2004, WM_POWERBROADCAST message cannot received, I am really confused.

windows-api
· 7
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Welcome to Microsoft Q&A! Thanks for posting here. I can receive WM_POWERBROADCAST message on Windows 10 2004 build 19041.208. What's your build version? And since this message is automatically broadcast to top level window without registering, could you show related code about how do you register the system message notification?

0 Votes 0 ·

thanks for reply. My build version is Windows 10 2004 build 19041.264. Related code is below,

RegisterPowerSettingNotification((HWND)(hwnd), &GUID_LIDSWITCH_STATE_CHANGE, DEVICE_NOTIFY_WINDOW_HANDLE);

0 Votes 0 ·

With this kind of problem, the more information you can give the better.
Are you trying to register for one of the notifications using RegisterPowerSettingNotification? Do you check the return to make sure that is returns success?

0 Votes 0 ·

thanks for reply. Related code is below,

RegisterPowerSettingNotification((HWND)(hwnd), &GUID_LIDSWITCH_STATE_CHANGE, DEVICE_NOTIFY_WINDOW_HANDLE);

I chedk the return value is Null, but I can still receive the WM_POWERBROADCAST message on my one computer, but annother one failed to receive the message.

work well computer version is Windows 10 1809 build 17763.1217.
work bad computer version is Windows 10 2004 build 19041.264.

0 Votes 0 ·

sorry, I checked the return value is not Null, on both computer.

0 Votes 0 ·
Show more comments

1 Answer

mkdr-6590 avatar image
0 Votes"
mkdr-6590 answered mkdr-6590 edited

The problem mostly is, that your laptop is now forced into modern standby, which started (the force of modern standby, not modern standby itself) with 2004. If you use modern standby, you need to register and unregister for notifications like this:

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-registersuspendresumenotification

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-unregistersuspendresumenotification

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

[citation needed]
Modern Standby is the evolution of Connected Standby which. Modern Standby has been available throughout all of Windows 10 and Connected Standby was added with either 8 or 8.1. This means that 1903/1909, 1809, 1803... all go into modern standby if they get the chance.
While I can't fully test it out since my Surface is blocked from upgrading, RegisterSuspendResumeNotification does not notify when my Surface goes to Modern Standby in 1909. The only times that I get the notifications that it mentions is when it is in standby for long enough for it to actually sleep. Basically, because Modern Standby does not change the sleep state, it does not notify about the change in power mode.


0 Votes 0 ·

No, what I posted above is the correct answer to the issue in this post. You dont understand. Since 2004 modern standby is forced on all laptops and devices which support it, you cant disable it anymore. See the reddit post here about this: https://www.reddit.com/r/Dell/comments/h0r56s/getting_back_s3_sleep_and_disabling_modern/

If you set for example CsEnabled = 0 before 2004, youll end up in S3 mode, thread poster mostly used that, or some other way to force S3.

Tested it and it shows 0x4, 0x12 and 0x7 events for modern standby trigger and wake up. Just a quick 5 seconds sleep test.

I am 99% sure, this is what happened for the thread poster. He didnt have modern standby before, and with 2004 now have => meaning Windows is in modern standby mode, and if you want the events to work in modern standby mode, you need to register them to work. I tested this already.

What you mean it is blocked, just update manually: https://www.microsoft.com/en-us/software-download/windows10

0 Votes 0 ·