Detecting USB Drive Removal in a C Program. you need to open a file on the drive and pass a handle to this file to the RegisterDeviceNotification. MSDN; Azure; Windows; PowerShell. HDEVNOTIFY WINAPI RegisterDeviceNotification. Services can use the RegisterDeviceNotification function to register. hardware add/remove with WM_DEVICECHANGE and RegisterDeviceNotification. Detecting Hardware Insertion and/or Removal. see MSDN Handling DIF. An application can register for device change notifications using RegisterDeviceNotification Function (Windows) API. When an application or service calls. An application can register for device change notifications using RegisterDeviceNotification Function (Windows) API. When an application or service calls. RegisterDeviceNotification on MSDN Please edit this page! Do you have. helpful tips or sample code to share for using this API in managed code? corrections to the. Use RegisterDeviceNotification() for ALL USB devices. DEV_BROADCAST_DEVICEINTERFACE flag in the RegisterDeviceNotification(). blogs.msdn.com/doronh/archive. Check for device change (add/remove) events. //msdn.microsoft. false to be notified for all devices. /param public static void RegisterDeviceNotification. I have a service that uses RegisterDeviceNotification to watch for changes with mounted drives. The process is as follows:- I am writing a C class library for a WPF application. The class library should raise an event whenever some USB device is plugged in/plugged out. I am.