Sunday, April 25, 2010

Determine list of printers installed in C# (.Net Framework)

1. Add System.Drawing library as reference.

2. Import the System.Drawing.Printing.
using System.Drawing.Printing;

3. PrinterSettings.InstalledPrinters is a string collection of the printer names installed on the machine

Example to output all printers on Console:


using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing.Printing;
using System.Windows.Forms;

namespace PrintersDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            for(int i = 0; i < PrinterSettings.InstalledPrinters.Count; i++)
            {
                Console.WriteLine(PrinterSettings.InstalledPrinters[i]);
            }

            Console.ReadLine();
        }
    }
}

2 comments:

Be Meo said...

i visited your site , it's very nice...wellcome to my blog ! thank you so much!
http://www.tech24h.us/

Sara said...

Awesome logic! keep them coming!
Free Software Download