Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine the IP Address of a Printer in C#

I would like to determine the IP address of a printer, using C# (.NET 2.0). I have only the printer share name as set up on the Windows OS, in the format \\PC Name\Printer Name. The printer is a network printer, and has a different IP address to the PC. Does anyone have any pointers?

Thanks in advance for your help.

Regards, Andy.

like image 860
Tangiest Avatar asked Mar 24 '09 10:03

Tangiest


People also ask

How do I find the IP address of an old printer?

a) Press the Windows "Start" button and select "Control Panel." b) Select "Hardware and Sound" and choose "Devices and Printers." c) Right-click on the printer you want to check the IP address and click on "Properties."

How do I find IP address of printer on USB?

Right-click your printer and select properties. Head into the Ports tab and the first column you'll see will display the IP address of your printer. If your printer is connected to your router via USB then the router will be acting as a printer server.


2 Answers

Just adding an another solution here using .Net Framework 4.0 or higher

Using System.Printing

 var server = new PrintServer();
            var queues = server.GetPrintQueues(new[] { EnumeratedPrintQueueTypes.Local, EnumeratedPrintQueueTypes.Connections });
            foreach (var queue in queues)
            {
                string printerName = queue.Name;
                string printerPort = queue.QueuePort.Name;
             }
like image 77
Jay Avatar answered Oct 16 '22 16:10

Jay


Check this question: How to get Printer Info in C#.NET?. I think that you have to get the property PortName from the WMI properties.

like image 5
Panos Avatar answered Oct 16 '22 15:10

Panos