コード例 #1
0
        public static List <LibUsb0Registry> GetDevicesByInterfaceClass(Guid classGuid)
        {
            List <LibUsb0Registry> deviceList = new List <LibUsb0Registry>();
            IList <DeviceNode>     usbdevices = DeviceNode.GetDevices(classGuid);

            foreach (DeviceNode device in usbdevices)
            {
                LibUsb0Registry regInfo = GetDeviceForDeviceNode(device, classGuid);
                if (regInfo != null)
                {
                    deviceList.Add(regInfo);
                }
            }
            return(deviceList);
        }
コード例 #2
0
 public LibUsb0Device(String path, LibUsb0Registry registry)
 {
     DeviceFilename = path;
     this.Registry  = registry;
     DeviceHandle   = Kernel32.CreateFile(DeviceFilename,
                                          NativeFileAccess.SPECIAL,
                                          NativeFileShare.NONE,
                                          IntPtr.Zero,
                                          NativeFileMode.OPEN_EXISTING,
                                          NativeFileFlag.FILE_FLAG_OVERLAPPED,
                                          IntPtr.Zero);
     if (DeviceHandle.IsInvalid || DeviceHandle.IsClosed)
     {
         throw new Win32Exception();
     }
     ThreadPool.BindHandle(DeviceHandle);
 }