USB NotifyTop

This is a simple Delphi/Pascal unit to get notified when an USB device is connected or disconnected. This works on the Windows platform.


The constructor of the class (TMDUsbNotify) expects a GUID identifying the USB device. To get a notification for all devices, use the GUID_DEVINTERFACE_USB_DEVICE GUID.

To get the GUID for a certain device contact your vendor or look here.

A current list of Device Interface GUIDs can be found under the following registry key:

Also these CodeProject articles may be of interest:


This example demonstrates how to get notified when a Garmin USB GPS device is connected or disconnected.

Garmin GPS

How does it work?Top

It basically uses the RegisterDeviceNotification function and waits for the WM_DEVICECHANGE window message.


It seems that the application must be run in the GUI subsystem, i.e. you can’t use the unit in a console program.