private static IHidDeviceInformation InfoFromData(SafeDeviceInfoSetHandle infoList, SP_DEVICE_INTERFACE_DATA interfaceData) { var path = SetupDiGetDeviceInterfaceDetail(infoList, interfaceData, IntPtr.Zero); using (var device = Win32HidDevice.TryFromPath(path, 0)) { if (device == null) { if (log.IsDebugEnabled) { log.Debug($"Unable to open device {path}"); } return(null); } var information = new Win32HidDeviceInformationStored(device.Information); if (log.IsDebugEnabled) { log.Debug( $"Found device '{information.Product}' (PID=0x{information.ProductId:X2}) " + $"by '{information.Manufacturer}' (VID=0x{information.VendorId:X2})"); } return(information); } }
private static IHidDeviceInformation InfoFromData(SafeDeviceInfoSetHandle infoList, SP_DEVICE_INTERFACE_DATA interfaceData) { var path = SetupDiGetDeviceInterfaceDetail(infoList, interfaceData, IntPtr.Zero); using (var device = Win32HidDevice.TryFromPath(path, 0)) { if (device == null) { if (log.IsDebugEnabled) { log.Debug($"Unable to open device {path}"); } return null; } var information = new Win32HidDeviceInformationStored(device.Information); if (log.IsDebugEnabled) { log.Debug( $"Found device '{information.Product}' (PID=0x{information.ProductId:X2}) " + $"by '{information.Manufacturer}' (VID=0x{information.VendorId:X2})"); } return information; } }