Solved

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

Posted on 2013-01-25
3
342 Views
Last Modified: 2013-01-28
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
Comment
Question by:jdcoburn
3 Comments
 
LVL 7

Expert Comment

by:tipsybroom
ID: 38820796
0
 

Author Comment

by:jdcoburn
ID: 38820949
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
 
LVL 4

Accepted Solution

by:
jiangsheng earned 500 total points
ID: 38822480
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

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question