From: Ilya on 14 Sep 2009 14:29 The IOCTLish way would be: 1. Use SetupAPI to open all hubs in the system: 1. Call SetupDiGetClassDevs(GUID_DEVINTERFACE_USB_HUB, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT) 2. Enumerate them with SetupDiEnumDeviceInterfaces to get the device interface path 3. Pass the device interface path to CreateFile to open the hub. 2. Call IOCTL_USB_GET_NODE_INFORMATION on the hub device handle to get the number of ports on each hub (USB_NODE_INFORMATION..u.HubInformation.HubDescriptor.bNumberOfPorts). 3. For all USB ports on the hub (1 to N), call IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME on the hub device handle, each time passing the port in the USB_NODE_CONNECTION_DRIVERKEY_NAME.ConnectionIndex field. Compare the resulting driver key name to the driver key name of your device. If it matches, you've hit the jackpot and now you know the hub/port the device is on. P.S. To find out the driver key name of your USB device (be it USB mass storage or whatever), locate its device node and gets its CM_DRP_DRIVER* / SPDRP_DRIVER** property. * through CM_Get_DevNode_Registry_Property ** through SetupDiGetDeviceRegistryProperty, if you like the SetupAPI way of doing things
From: sam d on 14 Sep 2009 18:40 Thank you all, especially Uwe and Ilya. Both of your solutions are good. "sam d" wrote: > My application needs to know to which motherboard USB port a USB drive is > connected. Is it correct that each motherboard USB port is always assigned > the same Enhanced USB Controller port number? > If so, how to get the Enhanced USB Controller port number for a plugged USB > high speed device? > I was hoping to get a child device for each connection index from the > Usbview example, but so far do not know how to do it. > Is there a Windows (XP) API allowing to do this? > If no APIs in user mode, how can it be done in kernel mode from a filter > driver?
First
|
Prev
|
Pages: 1 2 Prev: troubles with Inf file Next: "Your new hardware is installed and ready to use." |