Using PnP Target Device Change Notification
A driver registers for EventCategoryTargetDeviceChange notification on a device so the driver can be notified when the device is about to be removed. For example, if a driver opens a handle to a device, the driver should register for EventCategoryTargetDeviceChange notification on the device so the driver can close its handle when the PnP manager needs to remove the device.
Drivers can also use EventCategoryTargetDeviceChange notification for custom notification. (See Using PnP Custom Notification.)
The following subsections discuss how to register for target device change notification and how to handle target device change events in a PnP notification callback routine: