RegisterPowerSettingNotification function (winuser.h)

Registers the application to receive power setting notifications for the specific power setting event.


HPOWERNOTIFY RegisterPowerSettingNotification(
  [in] HANDLE  hRecipient,
  [in] LPCGUID PowerSettingGuid,
  [in] DWORD   Flags


[in] hRecipient

Handle indicating where the power setting notifications are to be sent. For interactive applications, the Flags parameter should be zero, and the hRecipient parameter should be a window handle. For services, the Flags parameter should be one, and the hRecipient parameter should be a SERVICE_STATUS_HANDLE as returned from RegisterServiceCtrlHandlerEx.

[in] PowerSettingGuid

The GUID of the power setting for which notifications are to be sent. For more information see Registering for Power Events.

[in] Flags

Value Meaning
Notifications are sent using WM_POWERBROADCAST messages with a wParam parameter of PBT_POWERSETTINGCHANGE.
Notifications are sent to the HandlerEx callback function with a dwControl parameter of SERVICE_CONTROL_POWEREVENT and a dwEventType of PBT_POWERSETTINGCHANGE.

Return value

Returns a notification handle for unregistering for power notifications. If the function fails, the return value is NULL. To get extended error information, call GetLastError.


Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header winuser.h (include Windows.h)
Library User32.lib
DLL User32.dll
API set ext-ms-win-ntuser-powermanagement-l1-1-0 (introduced in Windows 8)

See also

Power Management Functions

Registering for Power Events