Solved

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

Posted on 2013-01-25
3
338 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
Comment Utility
0
 

Author Comment

by:jdcoburn
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: Lee
Windows 7 Ultimate and Enterprise (and 2008 R2) introduced a new feature you may not be aware of - Boot from VHD.   Boot from VHD (or what Microsoft refers to asNative Boot allows you to install Windows to a VHD (Virtual Hard Disk) file that is t…
OfficeMate Freezes on login or does not load after login credentials are input.
This Micro Tutorial will teach you how to the overview of Microsoft Security Essentials. This is a free anti-virus software that guards your PC against viruses, spyware, worms, and other malicious software. This will be demonstrated using Windows…
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum editing capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now