• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 359
  • Last Modified:

Notification to a running application of a USB device connecting to the computer.

hi - i'm using VS2010 and .net 4 running on Windows 7. I want my app to respond to a specific usb device being connected to the computer - while the app is running. is there an event that i can trap? can you provide some code that would show how the call back would work?
the usb device is of my making, so i have some control over the device protocol. however it uses the ftdi chip to control the enumeration, so i don't have control over the device driver. it instantiates as a USB serial device. The actual device is an Arduino Nano.
thanks,
0
jdcoburn
Asked:
jdcoburn
1 Solution
 
tipsybroomCommented:
0
 
jdcoburnAuthor Commented:
thanks, but this shows up as a serial device (COM port). i suppose i could scan for a new COM port using the serial.ports but i would rather try and get a notification.
0
 
jiangshengCommented:
There's a device change notification via the Win32_DeviceChangeEvent WMI provider. However, this provider doesn't really tell if a new device is connected via USB right away.  You can enumerate USB devices via Win32_USBControllerDevice and see what's changed.

It may be easier to just pinvoke RegisterDeviceNotification and pass GUID_DEVINTERFACE_USB_DEVICE as the filter's class type.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now