08-网络操作/局域网端口扫描/ScanPort/Form1.cs

(开头部分) 7KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.DirectoryServices;
using System.Net;
using System.Net.Sockets;
using System.Threading;

namespace ScanPort
{
    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);
                        }
                    }
                }
后面还有 115 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读 AI

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。