开发者

How to access a printer name from IP on network in C#?

I can get to the printer with the name "\\xxxx\[name of printer]" but have no idea how to access this with only the IP of the printer. Any ideas?

EDIT: The answers seem to suggest that I can simply swap out the printer name for the IP address of the printer, however this does not seem to be the case. Any MORE ideas?

UPDATE: the reason for addressing the printer as an IP is that the networking guys gave all of the printers the same share name, so I have 开发者_JAVA技巧no way to distinguish them, other than their IP.


Exact same way.

\\1.2.3.4\somesharedprinter

Where "1.2.3.4" is the IP address of whatever is sharing the printer.

Edit:

Even if your printer has a built-in network interface, let's mentally separate the printer from the print server for a moment.

When you have a computer, let's call it Bob, and you share a printer, let's call it printy, you can access it like this:

\\Bob\printy

The first part of this address is the hostname or IP address. If Bob's IP address was 1.2.3.4, you could easily use this address instead:

\\1.2.3.4\printy

Now it sounds like your printer has a built-in print server which allows it to essentially share itself over the network. Most of these print servers are completely compatible with Windows File/Printer Sharing. So if the printer's IP is 2.3.4.5, we could use an address like this:

\\2.3.4.5\something

You want the something part, yes? To do this we need to enumerate the shares on that print server. You can do that with the code found here: http://www.codeproject.com/KB/IP/networkshares.aspx

To my knowledge, there is no managed way to get a list of shares on a server, so the link above is probably your best option for now.

I should also note that another common standard for print servers is the HP Jet Direct. You can't (well you can, but it's hackish) print to these until you install the printer on your system. To do this, you would go to Printers, Add Printer, choose a "local" (yes, counterintuitive) printer, then for port choose TCP/IP, and then enter the IP address.


If it has a host name it has an IP and they can be interchanged as needed.

\\MyMachine\MyPrinter

...equates to...

\\10.0.0.1\MyPrinter

If your printer is not on a machine and is a networked printer it will have its own IP address which you can use.

\\MyPrinter

...equates to...

\\10.0.0.2
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜