使用类:PrintDocument、PrinterSettings、IList、List
private static PrintDocument fPrintDocument = new PrintDocument(); /// <summary> /// Fetch local printer name. /// </summary> public static string DefaultPrinter { get { return fPrintDocument.PrinterSettings.PrinterName; } } /// <summary> /// fetch printer list of the machine,the first list is the default item. /// </summary> /// <returns></returns> public static IList<string> GetLocalPrinters() { IList<string> fPrinters = new List<string>(); fPrinters.Add(DefaultPrinter); foreach (string fPrinterName in PrinterSettings.InstalledPrinters) { if (!fPrinters.Contains(fPrinterName)) fPrinters.Add(fPrinterName); } return fPrinters; }
转载于:https://blog.51cto.com/lybing/656587