// private routine for enumerating a hub static void ListHub(USBHub Hub, List <USBDevice> DevList) { foreach (USBPort Port in Hub.GetPorts()) { if (Port.IsHub) { // recursive ListHub(Port.GetHub(), DevList); } else { if (Port.IsDeviceConnected) { DevList.Add(Port.GetDevice()); } } } }
// private routine for enumerating a hub static void SearchHubDriverKeyName(USBHub Hub, ref USBDevice FoundDevice, string DriverKeyName) { foreach (USBPort Port in Hub.GetPorts()) { if (Port.IsHub) { // recursive SearchHubDriverKeyName(Port.GetHub(), ref FoundDevice, DriverKeyName); } else { if (Port.IsDeviceConnected) { USBDevice Device = Port.GetDevice(); if (Device.DeviceDriverKey == DriverKeyName) { FoundDevice = Device; break; } } } } }
// private routine for enumerating a hub static void SearchHubInstanceID(USBHub Hub, ref USBDevice FoundDevice, string InstanceID) { foreach (USBPort Port in Hub.GetPorts()) { if (Port.IsHub) { // recursive SearchHubInstanceID(Port.GetHub(), ref FoundDevice, InstanceID); } else { if (Port.IsDeviceConnected) { USBDevice Device = Port.GetDevice(); if (Device.InstanceID == InstanceID) { FoundDevice = Device; break; } } } } }