DBT_DEVICEQUERYREMOVE event
The system broadcasts the DBT_DEVICEQUERYREMOVE device event to request permission to remove a device or piece of media. This message is the last chance for applications and drivers to prepare for this removal. However, any application can deny this request and cancel the operation.
To broadcast this device event, the system uses the WM_DEVICECHANGE message with wParam set to DBT_DEVICEQUERYREMOVE and lParam set as described following.
LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // WM_DEVICECHANGE
WPARAM wParam, // device-change event
LPARAM lParam // event-specific data
);
Parameters
-
hwnd
-
A handle to a window.
-
uMsg
-
The WM_DEVICECHANGE message identifier.
-
wParam
-
Set to DBT_DEVICEQUERYREMOVE.
-
lParam
-
A pointer to a structure identifying the device to remove. The structure consists of an event-independent header, followed by event-dependent members that describe the device. To use this structure, treat the structure as a DEV_BROADCAST_HDR structure, then check its dbch_devicetype member to determine the device type.
Return value
Return TRUE to grant permission to remove a device.
Return BROADCAST_QUERY_DENY to deny permission to remove a device.
Remarks
You must close all handles to the device or the device removal will fail.
Examples
For an example, see Processing a Request to Remove a Device.
Requirements
Requirement | Value |
---|---|
Minimum supported client |
Windows XP |
Minimum supported server |
Windows Server 2003 |
Header |
|