Detect when any unauthorized device is plugged into the USB port

onggie80

Member
Joined
Jan 26, 2004
Messages
8
Hi,

Does anyone know how i can detect when any unauthorized device is plugged into the USB port?

In my case an unauthorized device would include a USB mouse or a thumb drive. I need to be able to detect if any of these 2 are plugged into my machine.

Thanks
:)
 
Youd have to detect the initial install using the RMS API provided by the Win32 device subsystem. You can then query the device using [api]DeviceIOControl[/api] to determine its purpose.
 
Just to expand youd look for the WM_DEVICECHANGE message and filter for a "wParam" value that equates to DBT_DEVICEARRIVAL. LParam will be a pointer to a PDEV_BROADCAST_VOLUME if the device is of a media type (check for DBT_DEVTYP_VOLUME in the PDEV_BROADCAST_HDR structure).
 
Hi Derek,

Thanks for the pointer
I managed to solve my problem by using properties of Win32_USBControllerDevice

Realised that it returns a standard device ID for the particular USB device that i am checking for.

Thanks once again! :D
 
Back
Top