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 - WM_POWERBROADCAST
- 536 (0x218)
Message identifier.
- wParam
-
The power-management event. This parameter can be one of the following event identifiers.
Event Meaning - PBT_APMPOWERSTATUSCHANGE
- 10 (0xA)
Power status has changed.
- PBT_APMRESUMEAUTOMATIC
- 18 (0x12)
Operation is resuming automatically from a low-power state. This message is sent every time the system resumes.
- PBT_APMRESUMESUSPEND
- 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.
- PBT_APMSUSPEND
- 4 (0x4)
System is suspending operation.
- PBT_POWERSETTINGCHANGE
- 32787 (0x8013)
A power setting change event has been received.
Windows Server 2003 and Windows XP: The following event identifiers are also supported.Event Meaning - PBT_APMBATTERYLOW
- 9 (0x9)
Battery power is low. In Windows Server 2008 and Windows Vista, use PBT_APMPOWERSTATUSCHANGE instead.
- PBT_APMOEMEVENT
- 11 (0xB)
OEM-defined event occurred. In Windows Server 2008 and Windows Vista, this event is not available because these operating systems support only ACPI; APM BIOS events are not supported.
- PBT_APMQUERYSUSPEND
- 0 (0x0)
Request for permission to suspend. In Windows Server 2008 and Windows Vista, use the SetThreadExecutionState function instead.
- PBT_APMQUERYSUSPENDFAILED
- 2 (0x2)
Suspension request denied. In Windows Server 2008 and Windows Vista, use SetThreadExecutionState instead.
- PBT_APMRESUMECRITICAL
- 6 (0x6)
Operation resuming after critical suspension. In Windows Server 2008 and Windows Vista, use PBT_APMRESUMEAUTOMATIC instead.
- 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.
Windows Server 2003 and Windows XP: An application can return BROADCAST_QUERY_DENY to deny a PBT_APMQUERYSUSPEND or PBT_APMQUERYSUSPENDFAILED request.
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
|
Minimum supported client | Windows XP [desktop apps only] |
|---|---|
|
Minimum supported server | Windows Server 2003 [desktop apps only] |
|
Header |
|
See also
Send comments about this topic to Microsoft
Build date: 10/26/2012
