U can use gethostbyname, gethostbyaddr or same functions from WinSocket
library.
or use specific classes from .Net framework ..
like in this sample from msdn:
try
{
IPAddress hostIPAddress = IPAddress.Parse (IpAddressStrin g);
IPHostEntry hostInfo = Dns.GetHostByAd dress(hostIPAdd ress);
// Get the IP address list that resolves to the host names contained in
// the Alias property.
IPAddress[] address = hostInfo.Addres sList;
// Get the alias names of the addresses in the IP address list.
String[] alias = hostInfo.Aliase s;
Console.WriteLi ne("Host name : " + hostInfo.HostNa me);
Console.WriteLi ne("\nAliases :");
for(int index=0; index < alias.Length; index++) {
Console.WriteLi ne(alias[index]);
}
Console.WriteLi ne("\nIP address list : ");
for(int index=0; index < address.Length; index++) {
Console.WriteLi ne(address[index]);
}
}
catch(SocketExc eption e)
{
Console.WriteLi ne("SocketExcep tion caught!!!");
Console.WriteLi ne("Source : " + e.Source);
Console.WriteLi ne("Message : " + e.Message);
}
catch(FormatExc eption e)
{
Console.WriteLi ne("FormatExcep tion caught!!!");
Console.WriteLi ne("Source : " + e.Source);
Console.WriteLi ne("Message : " + e.Message);
}
catch(ArgumentN ullException e)
{
Console.WriteLi ne("ArgumentNul lException caught!!!");
Console.WriteLi ne("Source : " + e.Source);
Console.WriteLi ne("Message : " + e.Message);
}
catch(Exception e)
{
Console.WriteLi ne("Exception caught!!!");
Console.WriteLi ne("Source : " + e.Source);
Console.WriteLi ne("Message : " + e.Message);
}
"Uzi Baruch" <uz*******@hotm ail.com> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Hi!
i want to know if i have an ip address of a computer and its DNS server
name, if their is an windows API
that can resolve the computer name of the given ip address.
or vice verca - given a computer name and it's DNS server, i need to
obtain the IP address.
Thanks,
Uzi