The system sends 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 sends these messages through the WM_POWERBROADCAST message, setting the wParam parameter to the appropriate message. For example, the PBT_APMPOWERSTATUSCHANGE message 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 sends a PBT_APMQUERYSUSPEND message 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 sends a PBT_APMSUSPEND message immediately before suspending operation. This gives applications and drivers one last chance to prepare for the event. In many cases, the system sends these messages without requesting permission to do so. This happens, for example, if an application forces suspension with the SetSystemPowerState function.
The system sends the PBT_APMQUERYSUSPENDFAILED message whenever a requested event is denied. These messages notify applications and drivers to continue operation as usual.
The system sends the PBT_APMRESUMESUSPEND or PBT_APMRESUMECRITICAL message when system operation has been restored.