如何扫描局域网内所有机器的IP???
请问各位高手:如何用c#代码扫描局域网内所有机器的IP??
下面的代码为什么只能扫描本机的IP,局域网内其他的IP不能扫描??? --------------------编程问答-------------------- net view --------------------编程问答--------------------
public string IPList = "";
private void button4_Click(object sender, EventArgs e)
{
String ipPrefix = "192.168.0.";
for (int i = 2; i <= 255; i++)
{
Ping myPing = new Ping();
string strScanIPAdd = ipPrefix + i.ToString();
myPing.PingCompleted += new PingCompletedEventHandler(_myPing_PingCompleted);
myPing.SendAsync(strScanIPAdd, 1000, null);
}
MessageBox.Show(IPList);
}
private void _myPing_PingCompleted(object sender, PingCompletedEventArgs e)
{
if (e.Reply.Status == IPStatus.Success)
{
IPList += e.Reply.Address.ToString()+"\n";
}
}
补充:.NET技术 , C#