LibUsbDotNet does not list USB printer

570 Views Asked by At

I have this code in my C# program:

UsbRegistry reg = null;
if (productId == 0)
    reg = UsbDevice.AllDevices.FirstOrDefault(d => d.Vid.Equals(vendorId));
else
    reg = UsbDevice.AllDevices.FirstOrDefault(d => d.Vid.Equals(vendorId) 
          && d.Pid.Equals(productId));

if (reg != null)
    reg.Open(out _device);

UsbDevice.AllDevices property only list a USB fingerprint device, even when I have a USB printer also connected to a USB connector.

Printer is firmly connected and turned on, and in fact, if I print using Winspool driver, it works.

I need to bypass Winspool driver but printing directly sending bytes to USB port where the printer is attached.

What may be happening here?

This has been cross-posted to this Github issue

1

There are 1 best solutions below

0
Ben Voigt On

On Windows, libusb only supports a few drivers, please read https://github.com/libusb/libusb/wiki/FAQ#How_to_use_libusb_under_Windows

Your fingerprint device is found because it uses the HID driver (probably). Your printer is not HID, nor WinUSB.sys, nor LibusbK.sys It doesn't use "winspool driver" either (as your question wrongly claims). Winspool is a service not a device driver.

Use the printer API to find the device path, then open it with CreateFile and write to it. See the question you should have asked.