无论用WMI的Win32_Printer class
还是foreach(string iprt in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
this.DropDownList1.Items.Add(iprt);
我得到的都只是本地的打印机
代码如下:
ManagementObjectSearcher query;
ManagementObjectCollection queryCollection;
string deviceID = null;
// Get DeviceID from the Printer class using the name as search criteria
string queryString = "SELECT DeviceID FROM Win32_Printer";
query = new ManagementObjectSearcher(queryString);
queryCollection = query.Get();
// should only contain one entry
foreach( ManagementObject mo in queryCollection )
{
deviceID = mo["DeviceID"] as string;
this.PrintName.Items.Add(deviceID.ToString());
// deviceID = mo["DeviceID"] as string;
// Console.Write(deviceID.ToString());
}
---------------------------------------------------------------
about more intro:
http://www.csdn.net/develop/read_article.asp?id=15346
---------------------------------------------------------------
I don't test the codes. But I think your codes(wmi) should run well.see it :http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_printer.asp
You can use WinAPI 'EnumPrinters' to get all printers in your machine.