Skip to main content
PBT_APMPOWERSTATUSCHANGE event

Notifies applications of a change in the power status of the computer, such as a switch from battery power to A/C. The system also broadcasts this event when remaining battery power slips below the threshold specified by the user or if the battery power changes by a specified percentage.

A window receives this event through the WM_POWERBROADCAST message. The wParam and lParam parameters are set as described following.


LRESULT 
CALLBACK 
WindowProc( HWND hwnd,      // handle to window
            UINT uMsg,      // WM_POWERBROADCAST
            WPARAM wParam,  // PBT_APMPOWERSTATUSCHANGE
            LPARAM lParam); // zero

Parameters

hwnd

A handle to window.

uMsg
ValueMeaning
WM_POWERBROADCAST
536 (0x218)

Message identifier.

 

wParam
ValueMeaning
PBT_APMPOWERSTATUSCHANGE
10 (0xA)

Event identifier.

 

lParam

Reserved; must be zero.

Return value

No return value.

Remarks

An application should process this event by calling the GetSystemPowerStatus function to retrieve the current power status of the computer. In particular, the application should check the ACLineStatus, BatteryFlag, BatteryLifeTime, and BatteryLifePercent members of the SYSTEM_POWER_STATUS structure for any changes. This event can occur when battery life drops to less than 5 minutes, or when the percentage of battery life drops below 10 percent, or if the battery life changes by 3 percent.

Requirements

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

System Power Status
Power Management Events
GetSystemPowerStatus
SYSTEM_POWER_STATUS
WM_POWERBROADCAST