Version 0 of TWAPI and USB

Updated 2014-02-05 11:50:30 by APN

Some examples of using TWAPI with USB.

Enumerate human-friendly names for USB devices

proc usb_enum {} {
  set wmi [wmi_root]
  set devices [$wmi ExecQuery {Select * from win32_usbcontrollerdevice}]
  $devices -iterate device {
    set dependent [$device Dependent]
    if {[regexp -nocase {win32_pnpentity\.deviceid="(.*)"} $dependent -> id]} {
      set pnp_entities [$wmi ExecQuery "select * from win32_pnpentity where deviceid='$id'"]
      $pnp_entities -iterate pnp_entity {
        puts [$pnp_entity Description]
        $pnp_entity -destroy
      }
      $pnp_entities -destroy
    }
    $device -destroy
  }
  $devices -destroy
  $wmi -destroy
}
(tcl) 170 % usb_enum
USB Root Hub (xHCI)
USB Root Hub
Generic USB Hub
USB Composite Device
Lenovo EasyCamera
Intel(R) Centrino(R) Wireless Bluetooth(R) 4.0 + High Speed Adapter
....