2

如何使用 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);
}
4

1 回答 1

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));
}
于 2012-12-06T07:36:15.693 回答