views:

33

answers:

1

Is there a way, just using the win32 API, to find out what version of USB is available? The XPe build is pretty barebones and doesn't doesn't have WMI.

I considered the USBview technique: enumerate the USB hubs by opening \.\HCD0 through say \.\HCD9, use DeviceIoControl to get the hub name, and looking for an enhanced host controller. But to build this I'd need the DDK which I'm not familiar with and don't want to install unless I really have to.

Is there a simpler way?

A: 

As you mention, UsbView enumerates USB hubs and devices. Its source is in the DDK at ddk\xp\src\wdm\usb\usbview.

I found a simpler approach that was device-specific and worked in my situation. I was able to determine speed based on the maximum packet size for the device. The packet size is in struct member MaximumPacketSize in structure USBD_PIPE_INFORMATION. On MSDN, see OSRUSBFX2 which says "The maximum packet size depends on the speed" - the USB 2.0 size is 0x200 and the USB 1.1 size is 0x40. Search MSDN for OSRUSBFX2 for more info.

Although not as general-purpose as enumerating USB devices, the USBD_PIPE_INFORMATION approach might work in your situation and is much simpler.

Jim Fred