|
-
March 8th, 2010, 08:58 AM
#1
How to Detect When an USB Device has been unplugged
Hi,
I am developing an application where I have to determine if an USB Connector assigned to a COM Port has been pulled out.
The obvious approach which I tried was to detect the available COM Ports using SerialPort.GetPortNames(). Unfortunately, even after physically pulling it out, the Port Name list still shows the same port being present.
Obviously, any operations would now fail as the connection is no longer available, but how to do this without making any communication, that is, without sending or receiving data.
-
March 8th, 2010, 12:14 PM
#2
Re: How to Detect When an USB Device has been unplugged
http://www.pinvoke.net/default.aspx/...ification.html
should contain everything you need, or at least get you started.
-
March 9th, 2010, 01:59 AM
#3
Re: How to Detect When an USB Device has been unplugged
Thanks for the reply.
That would be one way to do this task.
However, one thing that I don't understand is why SerialPort.GetPortNames() will still show a COM that has been removed.
-
March 9th, 2010, 08:40 AM
#4
Re: How to Detect When an USB Device has been unplugged
The good old API route :
RegisterDeviceNotification
UnRegisterDeviceNotification
As pointed out by mariocatch ( ) is the best way to go
Last edited by HanneSThEGreaT; March 9th, 2010 at 08:42 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|