internal static bool Open(string devicePath, out WinHidDevice usbDevice) { usbDevice = null; SafeFileHandle sfhDev; bool bSuccess = WinHidApi.OpenDevice(out sfhDev, devicePath); if (bSuccess) { usbDevice = new WinHidDevice(WinHidApi, sfhDev, devicePath); } else UsbError.Error(ErrorCode.Win32Error, Marshal.GetLastWin32Error(), "Open", typeof(UsbDevice)); return bSuccess; }
/// <summary> /// Opens the USB device for communucation. /// </summary> /// <param name="usbDevice">Returns an opened WinUsb device on success, null on failure.</param> /// <returns>True on success.</returns> public bool Open(out WinHidDevice usbDevice) { usbDevice = null; if (String.IsNullOrEmpty(SymbolicName)) return false; if (WinHidDevice.Open(SymbolicName, out usbDevice)) { usbDevice.mUsbRegistry = this; return true; } return false; }