Platform SDK: Hardware

Power Management Policy

The system broadcasts a message to all applications and installable drivers whenever a power management event occurs or whenever an application calls the SetSystemPowerState function to suspend operation. The system broadcasts these events through the WM_POWERBROADCAST message, setting the wParam parameter to the appropriate power management event. For example, the PBT_APMPOWERSTATUSCHANGE event indicates a system power status change. You must ensure that your application responds to the WM_POWERBROADCAST message to properly stop activity when the system enters the sleeping state and to recover transparently when the system enters the working state. When the system enters the sleeping state, it closes network connections. The user can change the hardware configuration or power supply while the system is in the sleeping state.

The system broadcasts a PBT_APMQUERYSUSPEND event to request permission to suspend system operation. The system expects each application and driver to determine whether the requested event should occur and to return TRUE if it occurs, or return BROADCAST_QUERY_DENY otherwise. Any application or driver can deny the request and prevent the event from occurring.

The system broadcasts a PBT_APMSUSPEND event immediately before suspending operation. This gives applications and drivers one last chance to prepare for the event. In many cases, the system broadcasts these messages without requesting permission to do so. This happens, for example, if an application forces suspension with the SetSystemPowerState function.

The system broadcasts the PBT_APMQUERYSUSPENDFAILED event whenever a requested event is denied. These events notify applications and drivers to continue operation as usual.

The system broadcasts the PBT_APMRESUMESUSPEND or PBT_APMRESUMECRITICAL event when system operation has been restored. If an application received a PBT_APMSUSPEND event before the computer was suspended, it will receive the PBT_APMRESUMESUSPEND event. Otherwise, it will receive the PBT_APMRESUMECRITICAL event.