C# 如何得到局域网中的计算机名? private void ScanTarget() { string strIPAddress="192.168.1."; //Start scan address int nStrat = Int32.Parse("1"); //Finish scan address int nEnd =Int32.Parse("255"); //scan operation for(int i=nStrat;i<=nEnd;i++) { string strScanIPAdd = strIPAddress +i.ToString(); //convert to ip address IPAddress myScanIP = IPAddress.Parse(strScanIPAdd); try { //get dns information IPHostEntry myScanHost = Dns.GetHostByAddress(myScanIP); //get host name string strHostName =myScanHost.HostName.ToString(); this.listBox2.Items.Add(strScanIPAdd+"->"+strHostName+"\r"); } catch { continue; } }//for MessageBox.Show("ok"); } posted on 2005-04-29 15:11 K3 阅读( ...) 评论( ...) 编辑 收藏 转载于:https://www.cnblogs.com/sskset/archive/2005/04/29/147621.html