private void HqIp_Click(object sender, EventArgs e)
{
Ipxs.Items.Clear();
string Zjm= Dns.GetHostName();//获取本地主机名
string Bjip = Dns.GetHostEntry(Zjm).AddressList.FirstOrDefault<IPAddress>(a => a.AddressFamily.ToString().Equals("InterNetwork")).ToString();//获取本机Ip
string Ipduan = Bjip.Remove(Bjip.LastIndexOf("."));
Ping Juip = new Ping();
string data = "";
byte[] bueffer = Encoding.ASCII.GetBytes(data);
for (int i = 1; i <= 255; i++)
{
string pingip = Ipduan + "." + i.ToString();
PingReply pingReply = Juip.Send(pingip,60,bueffer);
if (pingReply.Status == IPStatus.Success)
{
Ipxs.Items.Add(pingip);
Ipxs.Refresh();
}
}