如何使用c#列出asp.net中的客户端打印机?
我的代码:这将列出连接到服务器的打印机。
ManagementScope scope = new ManagementScope(@"\root\cimv2");
scope.Connect();
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Printer");
foreach (ManagementObject printer in searcher.Get())
{
string printerName = printer["Name"].ToString().ToLower();
Response.Write("chethann ");
Response.Write(printerName);
}
答案 0 :(得分:0)
PrinterInformation info = new PrinterInformation();
var printers = info.GetPrinters();
foreach (var printer in printers)
{
Response.Write(string.Format("Machine Name : {0} - Printer Name: {1}", Environment.MachineName, printer.DeviceName));
}