Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0 USB WinForm
Hi everyone.
I am developing some application that uses device, with FTDI chip on board, connected to PC through USB. Application uses ft2xx.dll. It will be very nice If my application would be able to recognize device removal and insertion. I can do it with some timer, that constantly tries to write or read something from device, and according to success or fault it will tell to my application that the device is connected or disconnected. But it is an ugly solution for sure. I know there are events risen in Windows when I connect and disconnect device.
So my question is: How can I subscribe to those events in my Winforms C# application, and if I have this event, how would I know that this is the device I need? I mean that I need to be able to identify this devise also.
Important thing is: It is bad idea to try to identify device by it's serial number or some other ID, because those things changes from device to device, I need something like type-identifier. (When you plug in your iPhone, PC knows it is iPhone, no matter it is your's or the one your wife have, right?)
And another pain is: both x86 and x64 are meant to work.
 
I have searched for answer a bit, but unfortunately my low level knowledge of C++ limited my understanding quite a lot. So, may be someone have wrote C# wrapper for those things?
 
Any help will be appreciated, both links to relevant information and working code Smile | :)
 
Regards, Artem
Posted 10-Jun-12 20:46pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
 
please read my solution some time ago, a near similar question:
Working with USB Devices[^]
 
Especially following great CP-Article:
 
A USB Library to Detect USB Devices[^]
 
In addition there must be some hardware-id which is stored/recognized/integrated drivers of win (sometimes through windows update), if iphone was plugged in.
 
Unfortunately I'm not 100% sure, but I think PNP-ID/Device ID should be always the same id, you're right, serial number is unique.
 
Regards
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 George Jonsson 215
1 Kornfeld Eliyahu Peter 169
2 OriginalGriff 120
3 PIEBALDconsult 110
4 Zoltán Zörgő 99
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,294


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 13 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100