Monday, 15 April 2013

c# - Get Printer Names and number of trays -



c# - Get Printer Names and number of trays -

i trying display available printer names on server , number of trays associated them. how display number of trays associated printer?

i used next code. works doesn't display communicate information. should include messagebox? how display these information?

using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; using system.printing; using system.drawing.printing; using system.management; namespace find { class programme { static void main(string[] args) { var printerquery = new managementobjectsearcher("select * 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"); console.writeline("{0} (status: {1}, default: {2}, network: {3}", name, status, isdefault, isnetworkprinter); } } } }

your code works fine me. it's console window displaying info , exiting. seek adding console.readkey() @ end of main method, console session remains after displaying information.

at end of main method, add together like:

console.write("\ndone! press key exit..."); console.readkey();

c# asp.net printers tray network-printers

No comments:

Post a Comment