Upravit

Sdílet prostřednictvím


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.

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
WinUser.h (include Windows.h)

See also