Enlist Printer(s) on the System

By Mayur Dighe Sep 02, 2012
The Blog demonstrate a method to enlist the printer installed on the system.


About Classes used

 #1: An object of PrintDocument class, allow for setting the properties that describe how to print, and call the Print method to start the printing process.

#2:  PrinterSettings class, Specifies information about how a document is printed, including the printer that prints it, when printing from a Windows Forms application.

Namespace Required - System.Drawing.Printing

Controls used:

1.    ListView Control (lvPrinters)

2.    Button Control (btnGetPrinter & btnExit)

Here I implemented the Code for enlisting the printer(s) installed on the system.          

The Code: (do necessary changes)

1. Variables Declaration.

                        Boolean value = true;
                        String Default = "";


Listing 1

2. Search for Default Printer.

                   // Determine Default Printer Exist or Not
                   if ((new PrintDocument()).PrinterSettings.IsDefaultPrinter == value)
            // if Exist Fetch the Printer's Name
                  ListViewItem item = new ListViewItem(Default =
                  // Add the Default Printer's Name to ListView
            value = false// Reset Boolean Value to False

Listing 2

3. Search for Other Printer(s)

//Fetch All Installed Printer's Name
                   foreach (object var in PrinterSettings.InstalledPrinters)
                  // Compare Installed Printer(s) Name with Default Printer
                  if (Default != var.ToString())
                        ListViewItem item = new ListViewItem(var.ToString());

                        // Add Remaining Printer's Name to ListView

Listing 3

4. Now execute the Application and see the result (Figure 1).

Intended Result:

New Picture (4).png

Figure 1


In this piece of writing, using C# environment, we have seen how to retrieve printer(s) name installed on the system.

Mayur Dighe
Mayur Dighe

Mayur B. Dighe – is a Hobbyist Programmer and Engineering Student. He completed a Diploma in Computer Technology in 2011 and also currently pursuing IT Engineering from University of Pune, India.My Blog : &... Read more


Latest Blogs