how to get host name of all LAN systems using c#.net
through "net view" command am getting some systems host names, not able to access all the systems even though they are in the LAN. why so?
how to get host name of all LAN systems using c#.net
through "net view" command am getting some systems host names, not able to access all the systems even though they are in the LAN. why so?
Try this: (For no Active directory)
public static int GetAllIPAndHostNames()
{
string strHostName;
// Getting Ip address of local machine...
// First get the host name of local machine.
strHostName = Dns.GetHostName();
Console.WriteLine("Local Machine's Host Name: " + strHostName);
IPHostEntry remoteIP;
//using host name, get the IP address list..
IPHostEntry ipEntry = Dns.GetHostEntry(strHostName);
IPAddress[] addr = ipEntry.AddressList;
int i = 0;
while (i < addr.Length)
{
Console.WriteLine("IP Address {0}: {1} ", i, addr[i].ToString());
//HostNames
remoteIP = Dns.GetHostEntry((addr[i]));
Console.WriteLine("HostName {0}: {1} ", i, remoteIP.HostName);
i++;
}
return 0;
}
But, still I'm getting my local machine's hostname & it's IP. How would I get all the active IPs in my LAN? I've also tried with 'ManagementObjectSearcher', but the result is same. So, please help me asap as I'm in desperate position for sometime...