zoukankan      html  css  js  c++  java
  • 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");
            }
  • 相关阅读:
    搭建typescript练习环境
    原有vue项目支持typescript
    express使用session
    express使用cookie
    javascript原型链
    javascript事件循环
    express中间件及body-parser第三方中间件获取post传值
    express路由、静态托管、ejs模板引擎
    nodejs驱动mongodb 实现数据增删改查,将数据库数据渲染在页面,通过表单项数据库新增数据
    柏松分布
  • 原文地址:https://www.cnblogs.com/sskset/p/147621.html
Copyright © 2011-2022 走看看