PBT_APMQUERYSUSPEND event

PBT_APMQUERYSUSPEND is available for use in the operating systems specified in the Requirements section. Support for this event was removed in Windows Vista. Use SetThreadExecutionState instead.]

Requests permission to suspend the computer. An application that grants permission should carry out preparations for the suspension before returning.

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_APMQUERYSUSPEND
            LPARAM lParam); // action flags

Parameters

hwnd

A handle to window.

uMsg

Value Meaning
WM_POWERBROADCAST
536 (0x218)
Message identifier.

wParam

Value Meaning
PBT_APMQUERYSUSPEND
0 (0x0)
Event identifier.

lParam

The action flags. If bit 0 is 1, the application can prompt the user for directions on how to prepare for the suspension; otherwise, the application must prepare without user interaction. All other bit values are reserved.

Return value

Return TRUE to grant the request to suspend. To deny the request, return BROADCAST_QUERY_DENY.

Remarks

An application should process this event as quickly as possible. The application can prompt the user for directions on how to prepare for suspension only if bit 0 in the Flags parameter is set. However, if this message is issued because the user is closing the laptop lid, it will not be possible to prompt the user. Applications should respect that the user expects a certain behavior when they close the laptop lid or press the power button and allow the transition to succeed.

The system allows approximately 20 seconds for an application to remove the WM_POWERBROADCAST message that is sending the PBT_APMQUERYSUSPEND event from the application's message queue. If an application does not remove the message from its queue in less than 20 seconds, the system will assume that the application is in a non-responsive state, and that the application agrees to the sleep request. Applications that do not process their message queues may have their operations interrupted. After it removes the message from the message queue, an application can take as much time as needed to perform any required operations before entering the sleep state. Any operations that could take longer then 20 seconds should be performed at this time, since the system allows only 20 seconds for operations to complete during PBT_APMSUSPEND processing.

Requirements

Requirement Value
Minimum supported client
Windows XP [desktop apps only]
Minimum supported server
Windows Server 2003 [desktop apps only]
End of client support
Windows XP
End of server support
Windows Server 2003
Header
WinUser.h (include Windows.h)

See also