Solved

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

Posted on 2013-01-25
3
349 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

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…
When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
This Micro Tutorial will teach you the basics of configuring your computer to improve its speed. It will also teach you how to disable programs that are running in the background simultaneously. This will be demonstrated using Windows 7 operating…
This Micro Tutorial will teach you how to change your appearance and customize your Windows 7 interface to your unique preference. This will be demonstrated using Windows 7 operating system.

738 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