private void button1_Click(object sender, EventArgs e)
{
DirectoryEntry de = new DirectoryEntry();
ArrayList computer_name = new ArrayList();
de.Path = "WinNT://" + "yoursite.com";
foreach (DirectoryEntry d in de.Children)
{
if (d.SchemaClassName == "Computer")
{
computer_name.Add(d.Name);
}
}
foreach (string cn in computer_name)
{
GetAllIP(cn);
}
}
public void GetAllIP(string args)
{
try
{
string strHostName = "";
ArrayList ipaddr = new ArrayList();
ArrayList hostname = new ArrayList();
IPHostEntry ipEntry = Dns.GetHostByName(args);
IPAddress[] addr = ipEntry.AddressList;
int i = 0;
listBox1.Items.Add(addr[i].ToString());
listBox2.Items.Add(args);
}
catch { }
}
No comments:
Post a Comment