WM_POWERBROADCAST message
Notifies applications that a power-management event has occurred.
A window receives this message through its WindowProc function.
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 |
---|---|
|
Message identifier. |
wParam
The power-management event. This parameter can be one of the following event identifiers.
Event | Meaning |
---|---|
|
Power status has changed. |
|
Operation is resuming automatically from a low-power state. This message is sent every time the system resumes. |
|
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. |
|
System is suspending operation. |
|
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.
Remarks
The system always sends a PBT_APMRESUMEAUTOMATIC message whenever the system resumes. If the system resumes in response to user input such as pressing a key, the system also sends a PBT_APMRESUMESUSPEND message after sending PBT_APMRESUMEAUTOMATIC.
WM_POWERBROADCAST messages do not distinguish between different low-power states. An application can determine only that the system is entering or has resumed from a low-power state; it cannot determine the specific power state. The system records details about power state transitions in the Windows System event log.
To prevent the system from transitioning to a low-power state in Windows Vista, an application must call SetThreadExecutionState to inform the system that it is in use.
The following messages are not supported on any of the operating systems specified in the Requirements section:
- PBT_APMQUERYSTANDBY
- PBT_APMQUERYSTANDBYFAILED
- PBT_APMSTANDBY
- PBT_APMRESUMESTANDBY
Requirements
Requirement | Value |
---|---|
Minimum supported client |
Windows XP [desktop apps only] |
Minimum supported server |
Windows Server 2003 [desktop apps only] |
Header |
|