using System;using System.Collections.Generic;using System.Windows.Forms;using System.Drawing.Printing;namespace FindPrinterDemo{ public partial class Demo : Form { public Demo() { this.Text= "本地打印机列表"; ListBox fListBox = new ListBox(); fListBox.Dock = DockStyle.Fill; foreach (String fPrinterName in LocalPrinter.GetLocalPrinters()) fListBox.Items.Add(fPrinterName); this.Controls.Add(fListBox); } } ////// 标题:获取本地打印机信息 /// 作者:肖小勇 /// 日期:2009-09-22 /// public class LocalPrinter { private static PrintDocument fPrintDocument = new PrintDocument(); ////// 获取本机默认打印机名称 /// public static String DefaultPrinter { get { return fPrintDocument.PrinterSettings.PrinterName; } } ////// 获取本机的打印机列表。列表中的第一项就是默认打印机。 /// public static ListGetLocalPrinters() { List fPrinters = new List (); fPrinters.Add(DefaultPrinter); // 默认打印机始终出现在列表的第一项 foreach (String fPrinterName in PrinterSettings.InstalledPrinters) { if (!fPrinters.Contains(fPrinterName)) fPrinters.Add(fPrinterName); } return fPrinters; } }}