0

How can I get a list of all the connected USB printers using C#? I need to show in a Listbox the name of all USB printers.

Edit: System.Drawing.Printing.PrinterSettings.InstalledPrinters does not solve my problem, I need only USB printers, not installed printers.

Edit2: My real objective is get device instance ID from the printer name, which has been answered here: Figuring which printer name corresponds to which device ID. So, I need printer name take from a list of USB printers to use GetUSBPath(string PrinterName).

Community
  • 1
  • 1
ViniCoder
  • 648
  • 9
  • 15
  • 1
    Possible duplicate of [How to get the list of all printers in computer](http://stackoverflow.com/questions/2354435/how-to-get-the-list-of-all-printers-in-computer) – Ken White Oct 29 '16 at 20:52
  • try the `ManagementObjectSearcher` – Jim Oct 29 '16 at 22:44

1 Answers1

1

I used this code my old project i hope it helpfull for you =)

First you have to add this library: using System.Drawing.Printing;

foreach (string printers in PrinterSettings.InstalledPrinters)
        {
            comboBoxName.Items.Add(printers);
        }
  • Sorry, but this give me: Microsoft XPS Document Writer (wrong), HP Deskjet 3630 series (OK - usb), HP Deskjet 1010 series (OK - usb), Fax (wrong). I need only USB printers. – ViniCoder Oct 29 '16 at 22:26
  • You can remove thats on your control. That code will give you all printers. These are default :) – Gökhan Gökce Nov 02 '16 at 15:47