Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

USB Device Insertion/Removal Event Notification

356 views
Skip to first unread message

Michael Primeaux

unread,
Nov 21, 2002, 6:40:36 PM11/21/02
to
What Windows 2000 and Window XP API is there for registering for USB device
insertion and removal events?

Thanks,
Michael


Michael Primeaux

unread,
Nov 21, 2002, 6:40:36 PM11/21/02
to

Jim Cavalaris [MS]

unread,
Nov 26, 2002, 7:52:29 PM11/26/02
to
you can register for device interface arrival and removal notification events
for members of the GUID_DEVINTERFACE_USB_DEVICE device
interface class.

specify a NotificationFilter type of DBT_DEVTYP_DEVICEINTERFACE
(use a DEV_BROADCAST_DEVICEINTERFACE structure) and specify
GUID_DEVINTERFACE_USB_DEVICE in the dbcc_classguid field
as the device interface class.

(note that the GUID_DEVINTERFACE_USB_DEVICE GUID is also
defined as GUID_CLASS_USB_DEVICE in the windows 2000 DDK).

RegisterDeviceNotification:
http://msdn.microsoft.com/library/en-us/devio/base/registerdevicenotification.asp

Registering for Device Notification:
http://msdn.microsoft.com/library/en-us/devio/base/registering_for_device_notification.asp

Introduction to Device Interfaces:
http://msdn.microsoft.com/library/en-us/install/hh/install/setup-cls_8vs7.asp

when notified of a device interface DBT_DEVICEARRIVAL or
DBT_DEVICEREMOVECOMPLETE removal event (dbch_devicetype
is DBT_DEVTYP_DEVICEINTERFACE), the corresponding
DEV_BROADCAST_DEVICEINTERFACE structure will contain a path
you can use to access the device in the dbcc_name field.

DEV_BROADCAST_DEVICEINTERFACE:
http://msdn.microsoft.com/library/en-us/devio/base/dev_broadcast_deviceinterface_str.asp

if you open a handle to the device, you can register to receive removal-related
events about that specific device (DBT_DEVICEQUERYREMOVE,
DBT_DEVICEQUERYREMOVEFAILED, DBT_DEVICEREMOVEPENDING,
DBT_DEVICEREMOVECOMPLETE) by calling RegisterDeviceNotification with
a DBT_DEVTYP_HANDLE type NotificationFilter (DEV_BROADCAST_HANDLE
structure).

see the toaster "notify" sample in the windows XP DDK for an example of registering
for the various types of device notification events.

hope this helps,
jim.

"Michael Primeaux" <mjpri...@msn.com> wrote in message news:uTfW7bbkCHA.2580@tkmsftngp12...

Michael Primeaux

unread,
Dec 3, 2002, 8:01:01 PM12/3/02
to
Thanks, Jim. This helped out tremendously.


"Jim Cavalaris [MS]" <jam...@online.microsoft.com> wrote in message
news:OeAq$8alCHA.1928@tkmsftngp07...

0 new messages