msdn 说明: https://docs.microsoft.com/zh-cn/windows/desktop/Power/wm-powerbroadcast
LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // WM_POWERBROADCAST
WPARAM wParam, // power-management event
LPARAM lParam // function-specific data
);
Parameters
hwnd
A handle to window.
*uMsg*
Value | Meaning |
---|---|
WM_POWERBROADCAST 536 (0x218) | Message identifier. |
wParam
The power-management event. This parameter can be one of the following event identifiers.
Event | Meaning |
---|---|
10 (0xA) | Power status has changed. |
18 (0x12) | Operation is resuming automatically from a low-power state. This message is sent every time the system resumes. |
7 (0x7) | Operation is resuming from a low-power state. This message is sent after PBT_APMRESUMEAUTOMATIC if the resume is triggered by user input, such as pressing a key. |
4 (0x4) | System is suspending operation. |
32787 (0x8013) | A power setting change event has been received. |
lParam
The event-specific data. For most events, this parameter is reserved and not used.
If the wParam parameter is PBT_POWERSETTINGCHANGE, the lParam parameter is a pointer to a POWERBROADCAST_SETTING structure.
Return value
An application should return TRUE if it processes this message.
通过监视PC Power状态,实现应用程序在不同Power状态下对应的行为。