TWAPI and USB

Difference between version 0 and 1 - Previous - Next
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 -cleanup 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 -cleanup 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
....
======


!!!!!!
%| [Category COM] | [Category Windows] | [Category System Administration]|%
!!!!!!