我的编程空间,编程开发者的网络收藏夹
学习永远不晚

C#实现扫描局域网内的所有IP和端口

短信预约 -IT技能 免费直播动态提醒
省份

北京

  • 北京
  • 上海
  • 天津
  • 重庆
  • 河北
  • 山东
  • 辽宁
  • 黑龙江
  • 吉林
  • 甘肃
  • 青海
  • 河南
  • 江苏
  • 湖北
  • 湖南
  • 江西
  • 浙江
  • 广东
  • 云南
  • 福建
  • 海南
  • 山西
  • 四川
  • 陕西
  • 贵州
  • 安徽
  • 广西
  • 内蒙
  • 西藏
  • 新疆
  • 宁夏
  • 兵团
手机号立即预约

请填写图片验证码后获取短信验证码

看不清楚,换张图片

免费获取短信验证码

C#实现扫描局域网内的所有IP和端口

实践过程

效果

代码

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    #region 实例化类对象及公共变量
    private Thread myThread;
    string StartIPAddress = "";
    string EndIPAddress = "";
    int intStrat =0;                          //开始扫描地址
    int intEnd = 0;                           //终止扫描地址
    string strIP = "";
    string strflag = "";                      //扫描到的IP地址
    #endregion

    private void button1_Click(object sender, EventArgs e)
    {
        try
        {
            if (button1.Text == "开始")
            { 
                listView1.Items.Clear();            //清空ListView控件中的项
                textBox1.Enabled = textBox2.Enabled = false;
                strIP = "";
                strflag = textBox1.Text;
                StartIPAddress = textBox1.Text;
                EndIPAddress = textBox2.Text;
                //开始扫描地址
                intStrat = Int32.Parse(StartIPAddress.Substring(StartIPAddress.LastIndexOf(".") + 1));
                //终止扫描地址
                intEnd = Int32.Parse(EndIPAddress.Substring(EndIPAddress.LastIndexOf(".") + 1));
                //指定进度条最大值
                progressBar1.Minimum = intStrat;
                //指定进度条最小值
                progressBar1.Maximum = intEnd;
                //指定进度条初始值
                progressBar1.Value = progressBar1.Minimum;
                timer1.Start();             //开始运行计时器
                button1.Text = "停止";      //设置按钮文本为停止
                //使用自定义方法StartScan实例化线程对象
                myThread = new Thread(new ThreadStart(this.StartScan));
                myThread.Start();                           //开始运行扫描IP的线程
            }
            else
            {
                textBox1.Enabled = textBox2.Enabled = true;
                button1.Text = "开始";      //设置按钮文本为开始
                timer1.Stop();              //停止运行计时器
                //设置进度条的值为最大值
                progressBar1.Value = intEnd;
                if (myThread != null)       //判断线程对象是否为空
                {
                    //判断扫描IP地址的线程是否正在运行
                    if (myThread.ThreadState == ThreadState.Running)
                    {
                        myThread.Abort();   //终止线程
                    }
                }
            }
        }
        catch { }
    }

    private void timer1_Tick(object sender, EventArgs e)
    {
        if (strIP != "")                           //判读是否有可用IP地址
        {
            if (strIP.IndexOf(',') == -1)
            {
                if (listView1.Items.Count > 0)
                {
                    for (int i = 0; i < listView1.Items.Count; i++)
                    {
                        //判断扫描到的IP地址是否与列表中的重复
                        if (listView1.Items[i].Text != strIP)
                        {
                            //向列表中添加扫描到的已用IP地址
                            listView1.Items.Add(strIP);
                        }
                    }
                }
                else
                    //向列表汇总添加扫描到的已用IP地址
                    listView1.Items.Add(strIP);
            }
            else
            {
                string[] strIPS = strIP.Split(',');
                for (int i = 0; i < strIPS.Length; i++)
                {
                    listView1.Items.Add(strIPS[i].ToString());
                }
            }
            strIP = "";
        }
        for (int i = 0; i < listView1.Items.Count; i++)
            listView1.Items[i].ImageIndex = 0;
        if (progressBar1.Value < progressBar1.Maximum)  //判断进度条的当前值是否超出其最大值
            progressBar1.Value = Int32.Parse(strflag.Substring(strflag.LastIndexOf(".") + 1));                    //将进度条的值加1
        if (strflag == textBox2.Text)  //判断正在扫描的IP地址是否是结束IP地址
        {
            timer1.Stop();                              //停止运行计时器
            textBox1.Enabled = textBox2.Enabled = true;
            button1.Text = "开始";                      //设置按钮文本为扫描
            MessageBox.Show("IP地址扫描结束!");
        }
    }

    private void Form1_FormClosed(object sender, FormClosedEventArgs e)
    {
        if (myThread != null)               //判断线程对象是否为空
        {
            //判断扫描IP地址的线程是否正在运行
            if (myThread.ThreadState == ThreadState.Running)
            {
                myThread.Abort();           //终止线程
            }
        }
    }

    #region 扫描局域网IP地址
    /// <summary>
    /// 扫描局域网IP地址
    /// </summary>
    private void StartScan()
    {
        //扫描的操作
        for (int i = intStrat; i <= intEnd; i++)
        {
            string strScanIP = StartIPAddress.Substring(0, StartIPAddress.LastIndexOf(".") + 1) + i.ToString();
            //转换成IP地址
            IPAddress myScanIP = IPAddress.Parse(strScanIP);
            strflag = strScanIP;
            try
            {
                //址获取DNS主机信息
                IPHostEntry myScanHost = Dns.GetHostByAddress(myScanIP);
                //获取主机名
                string strHostName = myScanHost.HostName.ToString();
                if (strIP == "")
                    strIP += strScanIP + "->" + strHostName;
                else
                    strIP += "," + strScanIP + "->" + strHostName;
            }
            catch { }
        }
    }
    #endregion
}
partial class Form1
{
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.IContainer components = null;

    /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }

    #region Windows 窗体设计器生成的代码

    /// <summary>
    /// 设计器支持所需的方法 - 不要
    /// 使用代码编辑器修改此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
        this.components = new System.ComponentModel.Container();
        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
        this.groupBox1 = new System.Windows.Forms.GroupBox();
        this.label1 = new System.Windows.Forms.Label();
        this.textBox1 = new System.Windows.Forms.TextBox();
        this.textBox2 = new System.Windows.Forms.TextBox();
        this.label2 = new System.Windows.Forms.Label();
        this.button1 = new System.Windows.Forms.Button();
        this.progressBar1 = new System.Windows.Forms.ProgressBar();
        this.timer1 = new System.Windows.Forms.Timer(this.components);
        this.imageList1 = new System.Windows.Forms.ImageList(this.components);
        this.listView1 = new System.Windows.Forms.ListView();
        this.groupBox1.SuspendLayout();
        this.SuspendLayout();
        // 
        // groupBox1
        // 
        this.groupBox1.Controls.Add(this.button1);
        this.groupBox1.Controls.Add(this.textBox2);
        this.groupBox1.Controls.Add(this.label2);
        this.groupBox1.Controls.Add(this.textBox1);
        this.groupBox1.Controls.Add(this.label1);
        this.groupBox1.Location = new System.Drawing.Point(4, -1);
        this.groupBox1.Name = "groupBox1";
        this.groupBox1.Size = new System.Drawing.Size(247, 73);
        this.groupBox1.TabIndex = 0;
        this.groupBox1.TabStop = false;
        // 
        // label1
        // 
        this.label1.AutoSize = true;
        this.label1.Location = new System.Drawing.Point(9, 21);
        this.label1.Name = "label1";
        this.label1.Size = new System.Drawing.Size(65, 12);
        this.label1.TabIndex = 0;
        this.label1.Text = "开始地址:";
        // 
        // textBox1
        // 
        this.textBox1.Location = new System.Drawing.Point(71, 18);
        this.textBox1.Name = "textBox1";
        this.textBox1.Size = new System.Drawing.Size(112, 21);
        this.textBox1.TabIndex = 1;
        this.textBox1.Text = "192.168.1.1";
        // 
        // textBox2
        // 
        this.textBox2.Location = new System.Drawing.Point(71, 45);
        this.textBox2.Name = "textBox2";
        this.textBox2.Size = new System.Drawing.Size(112, 21);
        this.textBox2.TabIndex = 3;
        this.textBox2.Text = "192.168.1.255";
        // 
        // label2
        // 
        this.label2.AutoSize = true;
        this.label2.Location = new System.Drawing.Point(9, 48);
        this.label2.Name = "label2";
        this.label2.Size = new System.Drawing.Size(65, 12);
        this.label2.TabIndex = 2;
        this.label2.Text = "结束地址:";
        // 
        // button1
        // 
        this.button1.Location = new System.Drawing.Point(189, 20);
        this.button1.Name = "button1";
        this.button1.Size = new System.Drawing.Size(50, 44);
        this.button1.TabIndex = 4;
        this.button1.Text = "开始";
        this.button1.UseVisualStyleBackColor = true;
        this.button1.Click += new System.EventHandler(this.button1_Click);
        // 
        // progressBar1
        // 
        this.progressBar1.Location = new System.Drawing.Point(4, 276);
        this.progressBar1.Name = "progressBar1";
        this.progressBar1.Size = new System.Drawing.Size(247, 15);
        this.progressBar1.TabIndex = 2;
        // 
        // timer1
        // 
        this.timer1.Interval = 1000;
        this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
        // 
        // imageList1
        // 
        this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
        this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
        this.imageList1.Images.SetKeyName(0, "ip.ico");
        // 
        // listView1
        // 
        this.listView1.FullRowSelect = true;
        this.listView1.LargeImageList = this.imageList1;
        this.listView1.Location = new System.Drawing.Point(4, 78);
        this.listView1.Name = "listView1";
        this.listView1.Size = new System.Drawing.Size(247, 192);
        this.listView1.SmallImageList = this.imageList1;
        this.listView1.StateImageList = this.imageList1;
        this.listView1.TabIndex = 3;
        this.listView1.UseCompatibleStateImageBehavior = false;
        this.listView1.View = System.Windows.Forms.View.List;
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(256, 293);
        this.Controls.Add(this.listView1);
        this.Controls.Add(this.progressBar1);
        this.Controls.Add(this.groupBox1);
        this.MaximizeBox = false;
        this.MinimizeBox = false;
        this.Name = "Form1";
        this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
        this.Text = "局域网IP地址扫描";
        this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Form1_FormClosed);
        this.groupBox1.ResumeLayout(false);
        this.groupBox1.PerformLayout();
        this.ResumeLayout(false);

    }

    #endregion

    private System.Windows.Forms.GroupBox groupBox1;
    private System.Windows.Forms.Button button1;
    private System.Windows.Forms.TextBox textBox2;
    private System.Windows.Forms.Label label2;
    private System.Windows.Forms.TextBox textBox1;
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.ProgressBar progressBar1;
    private System.Windows.Forms.Timer timer1;
    private System.Windows.Forms.ImageList imageList1;
    private System.Windows.Forms.ListView listView1;
}
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    #region 实例化类对象和公共变量
    //实例化DirectoryEntry对象,以便获得局域网组名和计算机名
    DirectoryEntry DEMain = new DirectoryEntry("WinNT:");
    TcpClient TClient = null;       //实例化连接侦听对象
    private Thread myThread;        //实例化线程对象
    string strName = "";            //记录选择的计算机名称
    int intflag = 0;                //扫描到的端口号
    int intport = 0;                //记录已用端口号
    int intstart = 0;               //扫描的开始端口号
    int intend = 0;                 //扫描的结束端口号
    #endregion

    private void Form1_Load(object sender, EventArgs e)
    {
        //遍历局域网中的工作组,并显示在下拉列表控件中
        foreach (DirectoryEntry DEGroup in DEMain.Children)
        {
            comboBox1.Items.Add(DEGroup.Name);
        }
    }

    private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        listBox1.Items.Clear();
        foreach (DirectoryEntry DEGroup in DEMain.Children)
        {
            //判断工作组名称
            if (DEGroup.Name.ToLower() == comboBox1.Text.ToLower())
            {
                //遍历指定工作组中的所有计算机名称,并显示在ListBox控件中
                foreach (DirectoryEntry DEComputer in DEGroup.Children)
                {
                    if (DEComputer.Name.ToLower() != "schema")
                    {
                        listBox1.Items.Add(DEComputer.Name);
                    }
                }
            }
        }
    }

    private void button1_Click(object sender, EventArgs e)
    {
        listView1.Items.Clear();            //清空ListView控件中的项
        try
        {
            if (button1.Text == "扫描")
            {
                intport = 0;                //初始化已用端口号
                //指定进度条最大值
                progressBar1.Minimum = Convert.ToInt32(textBox1.Text);
                //指定进度条最小值
                progressBar1.Maximum = Convert.ToInt32(textBox2.Text);
                //指定进度条初始值
                progressBar1.Value = progressBar1.Minimum;
                timer1.Start();             //开始运行计时器
                button1.Text = "停止";      //设置按钮文本为停止
                intstart = Convert.ToInt32(textBox1.Text);  //为开始扫描的端口号赋值
                intend = Convert.ToInt32(textBox2.Text);    //为结束扫描的端口号赋值
                //使用自定义方法StartScan实例化线程对象
                myThread = new Thread(new ThreadStart(this.StartScan));
                myThread.Start();                           //开始运行扫描端口号的线程
            }
            else
            {
                button1.Text = "扫描";      //设置按钮文本为扫描
                timer1.Stop();              //停止运行计时器
                //设置进度条的值为最大值
                progressBar1.Value = Convert.ToInt32(textBox2.Text);
                if (myThread != null)       //判断线程对象是否为空
                {
                    //判断扫描端口号的线程是否正在运行
                    if (myThread.ThreadState == ThreadState.Running)
                    {
                        myThread.Abort();   //终止线程
                    }
                }
            }
        }
        catch { }
    }

    private void Form1_FormClosed(object sender, FormClosedEventArgs e)
    {
        if (myThread != null)               //判断线程对象是否为空
        {
            //判断扫描端口号的线程是否正在运行
            if (myThread.ThreadState == ThreadState.Running)
            {
                myThread.Abort();           //终止线程
            }
        }
    }

    private void listBox1_Click(object sender, EventArgs e)
    {
        strName = listBox1.SelectedItem.ToString(); //记录选择的计算机名称
    }

    private void timer1_Tick(object sender, EventArgs e)
    {
        if (intport != 0)                           //判读是否有可用端口号
        {
            if (listView1.Items.Count > 0)
            {
                for (int i = 0; i < listView1.Items.Count; i++)
                {
                    //判断扫描到的端口号是否与列表中的重复
                    if (listView1.Items[i].Text != intport.ToString())
                    {
                        //向列表中添加扫描到的已用端口号
                        listView1.Items.Add(intport.ToString());
                    }
                }
            }
            else
                //向列表汇总添加扫描到的已用端口号
                listView1.Items.Add(intport.ToString());
            intport = 0;
        }
        if (progressBar1.Value < progressBar1.Maximum)  //判断进度条的当前值是否超出其最大值
            progressBar1.Value += 1;                    //将进度条的值加1
        if (intflag == Convert.ToInt32(textBox2.Text))  //判断正在扫描的端口号是否是结束端口号
        {
            timer1.Stop();                              //停止运行计时器
            button1.Text = "扫描";                      //设置按钮文本为扫描
            MessageBox.Show("端口扫描结束!");
        }
    }

    #region 扫描端口号
    /// <summary>
    /// 扫描端口号
    /// </summary>
    private void StartScan()
    {
        while (true)
        {
            for (int i = intstart; i <= intend; i++)
            {
                intflag = i;                            //记录正在扫描的端口号
                try
                {
                    TClient = new TcpClient(strName, i);//使用记录的计算机名称和端口号实例化侦听对象
                    intport = i;                        //记录已分配的端口号
                }
                catch { }
            }
        }
    }
    #endregion
}
partial class Form1
{
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.IContainer components = null;

    /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }

    #region Windows 窗体设计器生成的代码

    /// <summary>
    /// 设计器支持所需的方法 - 不要
    /// 使用代码编辑器修改此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
        this.components = new System.ComponentModel.Container();
        this.groupBox1 = new System.Windows.Forms.GroupBox();
        this.listBox1 = new System.Windows.Forms.ListBox();
        this.label2 = new System.Windows.Forms.Label();
        this.comboBox1 = new System.Windows.Forms.ComboBox();
        this.label1 = new System.Windows.Forms.Label();
        this.groupBox2 = new System.Windows.Forms.GroupBox();
        this.button1 = new System.Windows.Forms.Button();
        this.label4 = new System.Windows.Forms.Label();
        this.textBox2 = new System.Windows.Forms.TextBox();
        this.textBox1 = new System.Windows.Forms.TextBox();
        this.label3 = new System.Windows.Forms.Label();
        this.timer1 = new System.Windows.Forms.Timer(this.components);
        this.listView1 = new System.Windows.Forms.ListView();
        this.progressBar1 = new System.Windows.Forms.ProgressBar();
        this.groupBox1.SuspendLayout();
        this.groupBox2.SuspendLayout();
        this.SuspendLayout();
        // 
        // groupBox1
        // 
        this.groupBox1.Controls.Add(this.listBox1);
        this.groupBox1.Controls.Add(this.label2);
        this.groupBox1.Controls.Add(this.comboBox1);
        this.groupBox1.Controls.Add(this.label1);
        this.groupBox1.Location = new System.Drawing.Point(8, 7);
        this.groupBox1.Name = "groupBox1";
        this.groupBox1.Size = new System.Drawing.Size(127, 225);
        this.groupBox1.TabIndex = 0;
        this.groupBox1.TabStop = false;
        this.groupBox1.Text = "选择计算机";
        // 
        // listBox1
        // 
        this.listBox1.FormattingEnabled = true;
        this.listBox1.ItemHeight = 12;
        this.listBox1.Location = new System.Drawing.Point(22, 81);
        this.listBox1.Name = "listBox1";
        this.listBox1.Size = new System.Drawing.Size(94, 136);
        this.listBox1.TabIndex = 3;
        this.listBox1.Click += new System.EventHandler(this.listBox1_Click);
        // 
        // label2
        // 
        this.label2.AutoSize = true;
        this.label2.Location = new System.Drawing.Point(10, 65);
        this.label2.Name = "label2";
        this.label2.Size = new System.Drawing.Size(53, 12);
        this.label2.TabIndex = 2;
        this.label2.Text = "计算机:";
        // 
        // comboBox1
        // 
        this.comboBox1.FormattingEnabled = true;
        this.comboBox1.Location = new System.Drawing.Point(22, 39);
        this.comboBox1.Name = "comboBox1";
        this.comboBox1.Size = new System.Drawing.Size(94, 20);
        this.comboBox1.TabIndex = 1;
        this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
        // 
        // label1
        // 
        this.label1.AutoSize = true;
        this.label1.Location = new System.Drawing.Point(10, 22);
        this.label1.Name = "label1";
        this.label1.Size = new System.Drawing.Size(53, 12);
        this.label1.TabIndex = 0;
        this.label1.Text = "工作组:";
        // 
        // groupBox2
        // 
        this.groupBox2.Controls.Add(this.listView1);
        this.groupBox2.Controls.Add(this.button1);
        this.groupBox2.Controls.Add(this.label4);
        this.groupBox2.Controls.Add(this.textBox2);
        this.groupBox2.Controls.Add(this.textBox1);
        this.groupBox2.Controls.Add(this.label3);
        this.groupBox2.Location = new System.Drawing.Point(142, 7);
        this.groupBox2.Name = "groupBox2";
        this.groupBox2.Size = new System.Drawing.Size(196, 225);
        this.groupBox2.TabIndex = 1;
        this.groupBox2.TabStop = false;
        this.groupBox2.Text = "扫描计算机已用端口号";
        // 
        // button1
        // 
        this.button1.Location = new System.Drawing.Point(147, 38);
        this.button1.Name = "button1";
        this.button1.Size = new System.Drawing.Size(41, 23);
        this.button1.TabIndex = 5;
        this.button1.Text = "扫描";
        this.button1.UseVisualStyleBackColor = true;
        this.button1.Click += new System.EventHandler(this.button1_Click);
        // 
        // label4
        // 
        this.label4.AutoSize = true;
        this.label4.Location = new System.Drawing.Point(70, 43);
        this.label4.Name = "label4";
        this.label4.Size = new System.Drawing.Size(17, 12);
        this.label4.TabIndex = 4;
        this.label4.Text = "到";
        // 
        // textBox2
        // 
        this.textBox2.Location = new System.Drawing.Point(88, 39);
        this.textBox2.Name = "textBox2";
        this.textBox2.Size = new System.Drawing.Size(51, 21);
        this.textBox2.TabIndex = 3;
        // 
        // textBox1
        // 
        this.textBox1.Location = new System.Drawing.Point(16, 39);
        this.textBox1.Name = "textBox1";
        this.textBox1.Size = new System.Drawing.Size(51, 21);
        this.textBox1.TabIndex = 2;
        // 
        // label3
        // 
        this.label3.AutoSize = true;
        this.label3.Location = new System.Drawing.Point(8, 21);
        this.label3.Name = "label3";
        this.label3.Size = new System.Drawing.Size(125, 12);
        this.label3.TabIndex = 1;
        this.label3.Text = "请设定端口扫描范围:";
        // 
        // timer1
        // 
        this.timer1.Interval = 1000;
        this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
        // 
        // listView1
        // 
        this.listView1.Location = new System.Drawing.Point(16, 67);
        this.listView1.Name = "listView1";
        this.listView1.Size = new System.Drawing.Size(172, 150);
        this.listView1.TabIndex = 6;
        this.listView1.UseCompatibleStateImageBehavior = false;
        this.listView1.View = System.Windows.Forms.View.SmallIcon;
        // 
        // progressBar1
        // 
        this.progressBar1.Dock = System.Windows.Forms.DockStyle.Bottom;
        this.progressBar1.Location = new System.Drawing.Point(0, 236);
        this.progressBar1.Name = "progressBar1";
        this.progressBar1.Size = new System.Drawing.Size(342, 15);
        this.progressBar1.TabIndex = 2;
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(342, 251);
        this.Controls.Add(this.progressBar1);
        this.Controls.Add(this.groupBox2);
        this.Controls.Add(this.groupBox1);
        this.Name = "Form1";
        this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
        this.Text = "局域网端口扫描";
        this.Load += new System.EventHandler(this.Form1_Load);
        this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Form1_FormClosed);
        this.groupBox1.ResumeLayout(false);
        this.groupBox1.PerformLayout();
        this.groupBox2.ResumeLayout(false);
        this.groupBox2.PerformLayout();
        this.ResumeLayout(false);

    }

    #endregion

    private System.Windows.Forms.GroupBox groupBox1;
    private System.Windows.Forms.ListBox listBox1;
    private System.Windows.Forms.Label label2;
    private System.Windows.Forms.ComboBox comboBox1;
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.GroupBox groupBox2;
    private System.Windows.Forms.TextBox textBox1;
    private System.Windows.Forms.Label label3;
    private System.Windows.Forms.Label label4;
    private System.Windows.Forms.TextBox textBox2;
    private System.Windows.Forms.Button button1;
    private System.Windows.Forms.Timer timer1;
    private System.Windows.Forms.ListView listView1;
    private System.Windows.Forms.ProgressBar progressBar1;
}

到此这篇关于C#实现扫描局域网内的所有IP和端口的文章就介绍到这了,更多相关C#扫描局域网IP端口内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

C#实现扫描局域网内的所有IP和端口

下载Word文档到电脑,方便收藏和打印~

下载Word文档

猜你喜欢

C#实现扫描局域网内的所有IP和端口

这篇文章主要为大家详细介绍了如何利用C#实现扫描局域网内的所有IP和端口的功能,文中的示例代码讲解详细,对我们学习C#有一定的帮助,感兴趣的小伙伴可以跟随小编一起了解一下
2022-12-28

Node.JS中快速扫描端口并发现局域网内的Web服务器地址(80)

在 Node.JS 中进行端口扫描还是比较方便的,一般会有广播和轮询两种方式。即使用广播和扫描,使用广播发出的消息有时会被路由器屏蔽,所以并不可靠。 使用node.js中的net模块,可以直接尝试向目录主机的某个端口进行连接,如果能建立连接
2022-06-04

编程热搜

  • Python 学习之路 - Python
    一、安装Python34Windows在Python官网(https://www.python.org/downloads/)下载安装包并安装。Python的默认安装路径是:C:\Python34配置环境变量:【右键计算机】--》【属性】-
    Python 学习之路 - Python
  • chatgpt的中文全称是什么
    chatgpt的中文全称是生成型预训练变换模型。ChatGPT是什么ChatGPT是美国人工智能研究实验室OpenAI开发的一种全新聊天机器人模型,它能够通过学习和理解人类的语言来进行对话,还能根据聊天的上下文进行互动,并协助人类完成一系列
    chatgpt的中文全称是什么
  • C/C++中extern函数使用详解
  • C/C++可变参数的使用
    可变参数的使用方法远远不止以下几种,不过在C,C++中使用可变参数时要小心,在使用printf()等函数时传入的参数个数一定不能比前面的格式化字符串中的’%’符号个数少,否则会产生访问越界,运气不好的话还会导致程序崩溃
    C/C++可变参数的使用
  • css样式文件该放在哪里
  • php中数组下标必须是连续的吗
  • Python 3 教程
    Python 3 教程 Python 的 3.0 版本,常被称为 Python 3000,或简称 Py3k。相对于 Python 的早期版本,这是一个较大的升级。为了不带入过多的累赘,Python 3.0 在设计的时候没有考虑向下兼容。 Python
    Python 3 教程
  • Python pip包管理
    一、前言    在Python中, 安装第三方模块是通过 setuptools 这个工具完成的。 Python有两个封装了 setuptools的包管理工具: easy_install  和  pip , 目前官方推荐使用 pip。    
    Python pip包管理
  • ubuntu如何重新编译内核
  • 改善Java代码之慎用java动态编译

目录