public static IEnumerable <UsbDevice> GetConnectedDevices(string driveName) { foreach (var device in UsbHost.GetControllers().Select(x => x.GetRootHub()).SelectMany(x => UsbLogic.ListHub(x, driveName))) { yield return(device); } }
private static UsbDevice FindDeviceByInstanceID(string instanceID, string driveName) { UsbDevice foundDevice = null; foreach (var controller in UsbHost.GetControllers()) { UsbLogic.SearchHubInstanceID(controller.GetRootHub(), ref foundDevice, instanceID, driveName); if (foundDevice != null) { break; } } return(foundDevice); }
public static UsbDevice FindDeviceByDriverKeyName(string driverKeyName, string driveName) { UsbDevice foundDevice = null; foreach (var controller in UsbHost.GetControllers()) { UsbLogic.SearchHubDriverKeyName(controller.GetRootHub(), ref foundDevice, driverKeyName, driveName); if (foundDevice != null) { break; } } return(foundDevice); }
public static IEnumerable <UsbTreeItem> TextHost() { var depth = 0; foreach (var controller in UsbHost.GetControllers()) { yield return(new UsbTreeItem { Depth = depth, Value = $"C-{controller?.Name} ({controller?.Address})" }); foreach (var item in UsbTreeView.TextController(depth + 1, controller)) { yield return(item); } } }