Platform SDK: Hardware

DBT_DEVICEQUERYREMOVE

The system broadcasts the DBT_DEVICEQUERYREMOVE device event to request permission to remove a device. This message is the last chance for applications and drivers to prepare for the removal of the device. However, any application can deny this request and cancel the device removal.

To broadcast this device event, the system uses the WM_DEVICECHANGE message with wParam set to DBT_DEVICEQUERYREMOVE and lParam set as described following.

Parameters

wParam
Set to DBT_DEVICEQUERYREMOVE.
lParam
Pointer to a structure identifying the device to remove. To determine the structure type, treat the structure as a DEV_BROADCAST_HDR structure and check its dbch_devicetype member.

Return Values

Return TRUE to grant permission to remove a device.

Return BROADCAST_QUERY_DENY to deny permission to remove a device.

Remarks

On Windows NT/Windows 2000, you must close all handles to the device or the device removal will fail. This is not a requirement on Windows 95/98, but it is a good rule to follow and it should increase reliability.

Requirements

  Windows NT/2000: Requires Windows 2000.
  Windows 95/98: Requires Windows 95 or later.
  Header: Declared in Dbt.h.

See Also

Device Management Overview, Device Management Events, DEV_BROADCAST_HDR, WM_DEVICECHANGE