Detect an USB key

R

Romain TAILLANDIER

Hi group !

I am trying to detect my specific USB periphéral. It have a specific
VID and PID, but it is like an USB key

My goal is to detect plugged/unplugged USB peripherals, and check if
it is mine (using the VID PID), and do something at this time. in C#

Now,
- I am able to detect any USB peripheral connection, and react. i
found this on CodeProject in 5 or 6 different ways.
- I am able to know what is the volume name, and letter of all drives
(CodeProject)
- I am able to know if my Specific peripheral is connected by looking
at registry (HKLM\\SYSTEM\\CurrentControlSet\\Services\\USBSTOR\\Enum)
- I am able to found my drive using the registry (HKEY_CURRENT_USER
\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\CPC
\Volume) and parsing the name of the drive in a binary data key (very
dirty i know, but it is my only workaround, and i am not sure it work
for the moment)

But i can't get the link between the drive letter, and the VID / PID.

Please indicate me any way to perform this.

Thank you.
 
C

Cowboy \(Gregory A. Beamer\)

The guys who created SharpZipLib have a USB lib for .NET (which uses an
underlying USB lib created by someone else for COM). I am not sure if it
will give you everything, but that is where I would look first.

http://www.icsharpcode.net/OpenSource/SharpUSBLib/default.aspx

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box!
|
*************************************************
Hi group !

I am trying to detect my specific USB periphéral. It have a specific
VID and PID, but it is like an USB key

My goal is to detect plugged/unplugged USB peripherals, and check if
it is mine (using the VID PID), and do something at this time. in C#

Now,
- I am able to detect any USB peripheral connection, and react. i
found this on CodeProject in 5 or 6 different ways.
- I am able to know what is the volume name, and letter of all drives
(CodeProject)
- I am able to know if my Specific peripheral is connected by looking
at registry (HKLM\\SYSTEM\\CurrentControlSet\\Services\\USBSTOR\\Enum)
- I am able to found my drive using the registry (HKEY_CURRENT_USER
\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\CPC
\Volume) and parsing the name of the drive in a binary data key (very
dirty i know, but it is my only workaround, and i am not sure it work
for the moment)

But i can't get the link between the drive letter, and the VID / PID.

Please indicate me any way to perform this.

Thank you.
 
R

Romain TAILLANDIER

Thank you greg.

This seems good, but i search a full .net implementation, ere is a lot
of native code first then a C# use f this native implementation.
It is not acceptable in my case. I will contact the one who write the
C code, to help to convert it in C#. Seems to be a lot of work ....

Thank for other help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top