Processing a Request to Remove a Device

An application receives a DBT_DEVICEQUERYREMOVE message when a component in the system has decided to remove a given device. When the application receives this message, it should determine whether it is using the given device and either cancel or prepare for the removal. In the following example, the application processes the message by checking the type of device that is to be removed.

PDEV_BROADCAST_HDR pdbch;
PDEV_BROADCAST_VOLUME pdbcv;

case WM_DEVICECHANGE:
pdbch = (PDEV_BROADCAST_HDR) lParam;
switch (pdbch->dbch_devicetype) {
case DBT_DEVTYP_VOLUME:
pdbcv = (PDEV_BROADCAST_VOLUME) pdbch;
if (pdbcv->dbcv_flags == DBTF_MEDIA)
// pdbcv->dbcv_unitmask identifies which logical drive
}
return TRUE;
default:
return TRUE;
}

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
MegaDetailed.Net
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database