DBT_DEVICEREMOVECOMPLETE event

The system broadcasts the DBT_DEVICEREMOVECOMPLETE device event when a device or piece of media has been physically removed.

To broadcast this device event, the system uses the WM_DEVICECHANGE message with wParam set to DBT_DEVICEREMOVECOMPLETE 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_DEVICEREMOVECOMPLETE

lParam

A pointer to a structure identifying the device removed. 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.

Remarks

The system may broadcast a DBT_DEVICEREMOVECOMPLETE message without sending corresponding DBT_DEVICEQUERYREMOVE and DBT_DEVICEREMOVEPENDING messages. In such cases, the applications and drivers must recover from the loss of the device as best they can.

If media is being removed, the type of device arriving is a volume (the dbch_devicetype member is DBT_DEVTYP_VOLUME) and the change effects the media (the dbcv_flags member is DBTF_MEDIA).

Examples

For an example, see Detecting Media Insertion or Removal or Processing a Request to Remove a Device.

Requirements

Requirement Value
Minimum supported client
Windows XP
Minimum supported server
Windows Server 2003
Header
Dbt.h

See also

Device Events

Device Management Events

DEV_BROADCAST_HDR

WM_DEVICECHANGE