mapeo de impresoras de red c #

Is it possible to get network printer path using the following convention in C#


PrinterSettings.Installed printer gives out the printer name but not the path information.

Gracias por adelantado

preguntado el 01 de febrero de 12 a las 04:02

2 Respuestas

A quick and dirty way to get this information is to use the IWshRuntimeLibrary library (wshom.ocx).

WshNetwork network = new WshNetwork();
var printers = network.EnumPrinterConnections();
for (int i = 0; i < printers.Count(); i += 2)
     Console.WriteLine(printers.Item(i) + " \t" + printers.Item(i+1));

...But a more forward looking approach would be to use the information contained within Winspool's PRINTER_INFO_2 structure which is returned from the GetPrinter método.

Respondido 05 Feb 13, 08:02

This works for printer mapping. you need to make sure to add IWshRuntimeLibrary as a reference:

    using IWshRuntimeLibrary;
    private void MappPrinter()
        WshNetwork oNetwork = new WshNetwork();
        oNetwork.AddWindowsPrinterConnection("\\\\computername\\printername", "HPLJ6000","\\\\computername\\printername");

Respondido 01 Feb 12, 09:02

The OP is asking how to get the network path to the printer, not how to add it as a local printer. - M.Babcock

ooh, I just read the question title! BTW, I'm pretty sure using WMI queries the network path of the installed printers could be read. I will post the sample code here. sorry for wrong answer! - Afshin

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.