Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. USB devices, WMI and C#

USB devices, WMI and C#

Scheduled Pinned Locked Moved C#
csharphelptutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MarkB777
    wrote on last edited by
    #1

    Hi all, This is more of a WMI question than C#, but for lack of a more appropriate forum I am hoping someone here will know the answer. I have a USB printer connected to my computer, and I am trying to retrieve the USB port ID for it in a C# application (i.e VID/PID). I pulled the printer details from the WMI Win32_Printer class. The problem is the port field shows USB001 (which from what I understand is just a virtual allocation). I discovered the actual USB port was a parent device called 'USB Printing Support', and the printer USB device was a child of that. I pulled the WMI class Win32_USBControllerDevice and thought I found the relationship I need:

    // The dependent here is the 'USB Printing Support' device I want to associate with the printer (and USB001)
    Antecedent: \\MARK-PC-MKII\root\cimv2:Win32_USBController.DeviceID="PCI\\VEN_8086&DEV_1E2D&SUBSYS_84CA1043&REV_04\\3&11583659&0&D0"
    Dependent: \\MARK-PC-MKII\root\cimv2:Win32_PnPEntity.DeviceID="USB\\VID_04A9&PID_271A\\0000A1A6Q2NI"

    // The dependent here is the printer
    Antecedent: \\MARK-PC-MKII\root\cimv2:Win32_USBController.DeviceID="PCI\\VEN_8086&DEV_1E2D&SUBSYS_84CA1043&REV_04\\3&11583659&0&D0"
    Dependent: \\MARK-PC-MKII\root\cimv2:Win32_PnPEntity.DeviceID="USBPRINT\\CANONLBP6000/LBP6018\\7&2509A3F3&0&USB001"

    Unfortunately the PCI bus that both devices are related with is also related with a bunch of other devices, so I am not sure this approach will work. Does anybody know a way I could programically relate my printer device with its parent USB device (Preferably one which I could pull the USB device info once it has been related to the printer) Note: If I open the properties->details window for the 'USB Printing Support' device, there is a property called 'Children' which would be perfect... I just don't know how to get to it... ;-(. Thank you.

    Mark Brock I'm pretty sure there's a lot more to life than being really, really, ridiculously good looking

    K 1 Reply Last reply
    0
    • M MarkB777

      Hi all, This is more of a WMI question than C#, but for lack of a more appropriate forum I am hoping someone here will know the answer. I have a USB printer connected to my computer, and I am trying to retrieve the USB port ID for it in a C# application (i.e VID/PID). I pulled the printer details from the WMI Win32_Printer class. The problem is the port field shows USB001 (which from what I understand is just a virtual allocation). I discovered the actual USB port was a parent device called 'USB Printing Support', and the printer USB device was a child of that. I pulled the WMI class Win32_USBControllerDevice and thought I found the relationship I need:

      // The dependent here is the 'USB Printing Support' device I want to associate with the printer (and USB001)
      Antecedent: \\MARK-PC-MKII\root\cimv2:Win32_USBController.DeviceID="PCI\\VEN_8086&DEV_1E2D&SUBSYS_84CA1043&REV_04\\3&11583659&0&D0"
      Dependent: \\MARK-PC-MKII\root\cimv2:Win32_PnPEntity.DeviceID="USB\\VID_04A9&PID_271A\\0000A1A6Q2NI"

      // The dependent here is the printer
      Antecedent: \\MARK-PC-MKII\root\cimv2:Win32_USBController.DeviceID="PCI\\VEN_8086&DEV_1E2D&SUBSYS_84CA1043&REV_04\\3&11583659&0&D0"
      Dependent: \\MARK-PC-MKII\root\cimv2:Win32_PnPEntity.DeviceID="USBPRINT\\CANONLBP6000/LBP6018\\7&2509A3F3&0&USB001"

      Unfortunately the PCI bus that both devices are related with is also related with a bunch of other devices, so I am not sure this approach will work. Does anybody know a way I could programically relate my printer device with its parent USB device (Preferably one which I could pull the USB device info once it has been related to the printer) Note: If I open the properties->details window for the 'USB Printing Support' device, there is a property called 'Children' which would be perfect... I just don't know how to get to it... ;-(. Thank you.

      Mark Brock I'm pretty sure there's a lot more to life than being really, really, ridiculously good looking

      K Offline
      K Offline
      Kenneth Haugland
      wrote on last edited by
      #2

      I cant say I remember the code exactly, but I think you can get all the device id by the use of some dll. Sorry for the vague answer but I think youll find the related code in the book USB complete by Jan Axelson.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups