转载请注明来源:https://www.cnblogs.com/hookjc/

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using System.Collections;//ArrayList用
using System.Threading;
using System.Net;

namespace AllTest
{
public partial class Form7 : Form
{
public Form7(string ipPrefix, int startIP, int endIP)
//public Form7()
{
InitializeComponent();

this.startIP = startIP; 
            this.endIP = endIP; 
            this.ipPrefix = ipPrefix; 
            computerList = new ArrayList();
}

private int startIP = 0;
private int endIP = 0;
private string ipPrefix = "";
private ArrayList computerList = null;
  
        public void ScanComputers() 
        { 
            for(int i=startIP;i<=endIP;i++) 
            { 
                string scanIP = ipPrefix +"."+i.ToString(); 

                IPAddress myScanIP = IPAddress.Parse(scanIP); 

                IPHostEntry myScanHost = null; 

                string[] arr = new string[2]; 

                try 
                { 
                    myScanHost = Dns.GetHostByAddress(myScanIP); 
                } 

                catch 
                {
                    continue;
                }

                if (myScanHost != null) 
                {
                    arr[0] = myScanHost.HostName; 

                    arr[1] = scanIP; 

                    computerList.Add(arr);
        MessageBox.Show(myScanHost.HostName.ToString());
MessageBox.Show(scanIP.ToString());
                }
            }
        }

private void button1_Click(object sender, EventArgs e)
{
Form7 cai = new Form7("192.168.1", 134, 135);

Thread thScan = new Thread(new ThreadStart(cai.ScanComputers));

thScan.Start();

}
}

来源:python脚本自动迁移

winform 获得局域网内在线IP和计算机名,获取IP,多线程网络编程的更多相关文章

  1. server2003中看不到网上邻居内容,其他电脑无法通过计算机名和IP访问本计算机(但网上邻居中可访问到)

    现象1:server2003中看不到网上邻居内容,查看工作组计算机看到的是空列表, 现象2:其他电脑无法通过计算机名和IP访问本计算机(但网上邻居中可访问到)   访问提示:--Windows 200 ...

  2. 使用Python获取计算机名,ip地址,mac地址等等

    获取计算机名 # 获取计算机名,常用的方法有三种 import os import socket # method one name = socket.gethostname() print(name ...

  3. 查询局域网内在线电脑IP

    COLOR 0A CLS @ECHO Off Title 查询局域网内在线电脑IP :send @ECHO off&setlocal enabledelayedexpansion ECHO 正 ...

  4. 批处理 bat 查询局域网内在线电脑IP

    查看自己局域网的IP和物理网卡地址可以在 WIN+R –> 打开cmd 键入 arp -a 可以看到局域网中所有的在线IP COLOR 0A CLS @ECHO Off Title 查询局域网内 ...

  5. 查看局域网其它电脑的计算机名和IP

    一.下面脚本可查看局域网中的电脑计算机名和IP,保存下面文本至记事本.后缀改成bat COLOR 0A CLS @ECHO Off Title 查询局域网内在线电脑IP :send @ECHO off ...

  6. Android 获取本地外网IP、内网IP、计算机名等信息

    一.获取本地外网IP public static String GetNetIp() { URL infoUrl = null; InputStream inStream = null; try { ...

  7. 修改计算机名或IP后Oracle10g无法启动服务的解决办法

    修改计算机名或IP后Oracle10g无法启动服务的解决办法 遇到的问题,问题产生原因不详.症状为,windows服务中有一项oracle服务启动不了,报出如下错误. Windows 不能在 本地计算 ...

  8. 通过js获取计算机内网ip,计算机名,mac地址

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xht ...

  9. 关于是用dotnet获取本机IP地址+计算机名的方法

    印象中在maxscript帮助文档里找到过方法,但是当时没记下来.只能通过dotnet实现了. 如果电脑有无线网卡和本地连接,可能会出现乱码,也问了写dotnet的朋友,提供了一些思路,不过最终还是使 ...

随机推荐

  1. 详解Kalman Filter

    中心思想 现有: 已知上一刻状态,预测下一刻状态的方法,能得到一个"预测值".(当然这个估计值是有误差的) 某种测量方法,可以测量出系统状态的"测量值".(当然 ...

  2. JavaScript8种数据类型

    一.开门见山 在ES5的时候,我们认知的数据类型确实是 6种:Number.String.Boolean.undefined.object.Null. ES6 中新增了一种 Symbol .这种类型的 ...

  3. vue项目发布后,线上运行时刷新404

    修改nginx配置文件 location / { root ... index ... try_files $uri $uri/ /index.html; ---解决页面刷新404问题 } (参考官网 ...

  4. 2. node接口搭建--连接MongoDB数据库 (参考https://blog.csdn.net/ncepu_Chen/article/details/98725104#_337)

    1.使用mongoose连接MongoDB数据库 npm install mongoose 2.新建文件夹config存放数据库地址 3.安装MongoDB

  5. .net core中的Options重新加载机制

    Options是.net core提出的一种辅助配置机制,即选项. 目前,我们可以使用的Options有五种(源码): IOptionsFactory<>:Options的创建工厂(Sin ...

  6. InnoDB学习(八)之 聚簇索引

    InnoDB中,表数据文件本身就是以主键为索引的B+树,树的叶子节点存放一条条表数据,此索引树被称为表的聚簇索引.聚簇索引也称为聚集索引,聚类索引,簇集索引,聚簇索引确定表中数据的物理顺序. Inno ...

  7. Microsoft HoloLens 开发(2): 运行Hello World

    1.下载 MixedRealityToolkit-Unity (混合现实工具包) 什么是 MixedRealityToolkit-Unity ? 一个脚本和组件的集合,加速针对微软全息和Windows ...

  8. python自动化适应多接口的断言怎么做?

    最近做的接口自动化,遇到了很多模块的接口,返回的断言不太相同,在放在unnitest单元测试框架+ddt数据驱动,做参数时,发现不能只通过一个方式进行断言,那么,要怎么做才能做到适配当前所有接口的断言 ...

  9. Selenium_使用execute_script执行JavaScript(11)

    selenium的包含的方法已能完全满足UI自动化,但是有些时候又不得不用到执行JS的情况,比如在一个富文本框中输入1W个字,使用send_keys方法将经历漫长的输入过程,如果换成使用JS的inne ...

  10. vue-router 两个子路由之间相互跳转时出错

    patient页面跳转到apply页面后,再点击patient页面后无法跳回 解决方法:使用`${path + path1}` 来自为知笔记(Wiz)