Receive event before Windows enters standby or hib

2020-08-01 02:50发布

问题:

I'm working on a small chat application written in C++/Qt. My users are complaining that the connection is not shut down gracefully when they are closing the laptop lid and the computer enters standby.

Is there a Win32 hook available that is called when Windows is about to enter standby?

回答1:

WM_POWERBROADCAST



回答2:

Reimplement QCoreApplication::winEventFilter in your application to handle Windows standby events.