1
 _Printers = new PrintServer().GetPrintQueues(new[] { 
     EnumeratedPrintQueueTypes.Local, EnumeratedPrintQueueTypes.Connections});

The above code allows me to get a list of printers that available for me to print. One of the printer description is as below:

\\EYZR370\HP Color LaserJet 2605dn,HP Universal Printing PCL 6 (v5.1),

Now I'm trying to find the Ip Address of the printer manually using the following way:

1 -> Go to Control Panel
2-> View devices and printers
3-> Right-click on HP Color LaserJet 2605dn and select printer properties
4-> Select Port tab to see the IP Address

Now it shows the IPAddress for example 192.157.6.8

I'm wondering if 192.157.6.8 == EYZR370?

So I try the following way:

string hostName = System.Net.Dns.GetHostEntry("192.157.6.8").HostName;

Suprisingly hostName is having another string value that I've no clue what is it about.

Can anyone actually explain what is it all about regarding my case?

Updates:

I've done another test using the following way

  IPHostEntry hostEntry;

  hostEntry = Dns.GetHostEntry("EYZR370");

  //you might get more than one ip for a hostname since 
  //DNS supports more than one record

  if (hostEntry.AddressList.Length > 0)
  {
      //var ip = hostEntry.AddressList[0];
  }

I can see there are 6 data for hostEntry.AddressList but none of them match 192.157.6.8?

1 Answer 1

0

HostName property returns the primary host name.

You might want to check out the Aliases property which returns the list of possible aliases. If your machine has more than one DNS name which resolves to the 192.157.6.8, then you'll find it in the aforementioned property.

You might also want to try similar (though obsolete) methods like Dns.Resolve and Dns.GetHostByAddress. Some people have reported these methods work differently.

Is the printer configured properly? It seems the printer doesn't have a host name or the DNS isn't configured properly? Or maybe you have the wrong name altogether? Do you have access to its web control panel?

2
  • Have you tried resolving EYZR370 to an IP address?
    – Howie
    Feb 26, 2014 at 7:01
  • Please take a look at my updated question to see if I use the correct way to find the IP Address Feb 26, 2014 at 7:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.