示例#1
0
 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);
     }
 }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
                }
            }
        }