private DeviceInterface FindDevice()
{
Guid hidGuid = DeviceInformationSet.GetHidGuid();
using (var deviceInformationSet = new DeviceInformationSet(hidGuid, DiGetClassFlags.Present | DiGetClassFlags.DeviceInterface))
{
DeviceInterface deviceInterface = deviceInformationSet.GetDeviceInterfaces(hidGuid)
.Where(d => d.IsValidUsbDevice)
.FirstOrDefault(dis => dis.Details.DevicePath.Contains(VendorId) && dis.Details.DevicePath.Contains(ProductId));
if (deviceInterface == null)
{
_log.Debug("device not found");
}
else
{
_log.Debug("device found: " + deviceInterface.Details.DevicePath);
}
return deviceInterface;
}
}