C#获取本地打印机
工作中遇到打印机的问题了,所以想到用C#代码来获取打印机信息,代码如下:
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 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;
}
补充:软件开发 , C# ,