- 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);
- }
- }
-
-
-
-
-
- public class LocalPrinter
- {
- private static PrintDocument fPrintDocument = new PrintDocument();
-
-
-
- public static String DefaultPrinter
- {
- get { return fPrintDocument.PrinterSettings.PrinterName; }
- }
-
-
-
- public static List<String> GetLocalPrinters()
- {
- List<String> fPrinters = new List<string>();
- fPrinters.Add(DefaultPrinter);
- foreach (String fPrinterName in PrinterSettings.InstalledPrinters)
- {
- if (!fPrinters.Contains(fPrinterName))
- fPrinters.Add(fPrinterName);
- }
- return fPrinters;
- }
- }
- }
posted @
2012-12-04 20:25
Net-Spider
阅读(
731)
评论()
收藏
举报