Get the list of all printers in computer
from https://stackoverflow.com/questions/2354435/how-to-get-the-list-of-all-printers-in-computer
include System.Management
var printerQuery = new ManagementObjectSearcher("SELECT * from Win32_Printer");
foreach (var printer in printerQuery.Get())
{
var name = printer.GetPropertyValue("Name");
var status = printer.GetPropertyValue("Status");
var isDefault = printer.GetPropertyValue("Default");
var isNetworkPrinter = printer.GetPropertyValue("Network");
String printers =String.Format("'{0}' (Status: {1}, Default: {2}, Network: {3}",name, status, isDefault, isNetworkPrinter);
textBox1.Text = textBox1.Text + System.Environment.NewLine +printers;
Console.WriteLine("{0} (Status: {1}, Default: {2}, Network: {3}",
name, status, isDefault, isNetworkPrinter);
}
留言
張貼留言