Author Topic: How to find the device-path of USB device from HUB in C#  (Read 11222 times)

zhengt

  • Member
  • ***
  • Posts: 3
How to find the device-path of USB device from HUB in C#
« on: March 24, 2011, 07:57:22 pm »
Folks,

(1)  I did use Mr. Jan Axelson's C#-example(C#) to read/write my USB device. Very good.
(2)  Also, I did use USBViewer(C#) to find my USB devices through Controller-->Hub. Very good.

Question:
 How to find the device-path of my USB device through HUB?
 I did try to use DeviceIoControl in several ways, no results.

 Then, I tried to identify my USB devices from (1) and  ???(2).
 I did use SetupDiGetDeviceRegistryProperty for DeviceKey, (1) and (2) produced a little differece:
    (1)--> {745A17A0-74D3-11D0-B6FE-00A0C90F57DA}\0129   
    (2)--> {745A17A0-74D3-11D0-B6FE-00A0C90F57DA}\0127   
I did use SetupDiGetDeviceInstanceId for DeviceId, (1) and (2) produced a total differece:
    (1)--> HID\VID_089C&PID_0000\7&124EDCCF&0&0000
    (2)--> USB\VID_089C&PID_0000\6&33B481DB&0&1
I lost!!!

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: How to find the device-path of USB device from HUB in C#
« Reply #1 on: March 25, 2011, 11:08:51 am »
What is your end goal - what are you trying to accomplish?

Jan

zhengt

  • Member
  • ***
  • Posts: 3
Re: How to find the device-path of USB device from HUB in C#
« Reply #2 on: March 25, 2011, 06:16:41 pm »
Jan:

  The end goal is:
 Select one of my USB device from the TreeView (USBViewer), open it, then do read and write (Using your C# example)

  The difficults are:
   1) USBViewer does NOT provide the DevicePath of USB device. Only provide for Controller and HUB.
       But your sample does provide the DevicePath for every USB device.
   2) Driver keys from USBViewer and your sample show a little difference. (See my post).
   3) Instance Ids from USBViewer and your sample show a big difference. (See my post).
   4) No Serial Number.

  So, I do not know how to match between the two.

   Thanks


Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: How to find the device-path of USB device from HUB in C#
« Reply #3 on: March 25, 2011, 11:35:53 pm »
Applications should access devices via their device drivers (mass storage, HID, etc).

Jan