• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >C#教程 > c# 获得局域网主机列表实例

c# 获得局域网主机列表实例

作者: 字体:[增加 减小] 来源:互联网 时间:2017-05-28

通过本文主要向大家介绍了c#局域网聊天程序,c#局域网通信,c#局域网,c#局域网文件传输,c#局域网聊天源码等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Net;
using System.Threading;

namespace WindowLanSearch
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
  private System.Windows.Forms.TextBox textBox1;
  private System.Windows.Forms.Button button1;
  private string[,] LanHost;
  private System.Windows.Forms.ProgressBar progressBarSearch;
  private Thread[]  thread;
  private System.Windows.Forms.ListView listView1;
  private System.Windows.Forms.ColumnHeader columnHeader1;
  private System.Windows.Forms.ColumnHeader columnHeader2;
  private string str;
  /// <summary>
  /// 必需的设计器变量。
  /// </summary>
  private System.ComponentModel.Container components = null;

  public Form1()
  {
   //
   // Windows 窗体设计器支持所必需的
   //
   InitializeComponent();
   InitLanHost();
   progressBarSearch.Maximum = 255;

   //
   // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
   //
  }

  /// <summary>
  /// 数组初始化
  /// </summary>
  private void InitLanHost()
  {
   LanHost = new string[255,2];
   for (int i=0;i<255;i++)
   {
    LanHost[i,0] = "";
    LanHost[i,1] = "";
   }
  }

  /// <summary>
  /// 清理所有正在使用的资源。
  /// </summary>
  protected override void Dispose( bool disposing )
  {
   if( disposing )
   {
    if (components != null) 
    {
     components.Dispose();
    }
   }
   base.Dispose( disposing );
  }

  #region Windows 窗体设计器生成的代码
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {
   this.textBox1 = new System.Windows.Forms.TextBox();
   this.button1 = new System.Windows.Forms.Button();
   this.progressBarSearch = new System.Windows.Forms.ProgressBar();
   this.listView1 = new System.Windows.Forms.ListView();
   this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
   this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
   this.SuspendLayout();
   // 
   // textBox1
   // 
   this.textBox1.Location = new System.Drawing.Point(24, 40);
   this.textBox1.Multiline = true;
   this.textBox1.Name = "textBox1";
   this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Both;
   this.textBox1.Size = new System.Drawing.Size(176, 296);
   this.textBox1.TabIndex = 0;
   this.textBox1.Text = "";
   // 
   // button1
   // 
   this.button1.Location = new System.Drawing.Point(456, 40);
   this.button1.Name = "button1";
   this.button1.TabIndex = 1;
   this.button1.Text = "开始搜索";
   this.button1.Click += new System.EventHandler(this.button1_Click);
   // 
   // progressBarSearch
   // 
   this.progressBarSearch.Location = new System.Drawing.Point(32, 360);
   this.progressBarSearch.Name = "progressBarSearch";
   this.progressBarSearch.Size = new System.Drawing.Size(490, 24);
   this.progressBarSearch.TabIndex = 2;
   // 
   // listView1
   // 
   this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
                      this.columnHeader1,
                      this.columnHeader2});
   this.listView1.Location = new System.Drawing.Point(248, 40);
   this.listView1.Name = "listView1";
   this.listView1.Size = new System.Drawing.Size(184, 288);
   this.listView1.TabIndex = 5;
   // 
   // columnHeader1
   // 
   this.columnHeader1.Text = "dddd";
   // 
   // columnHeader2
   // 
   this.columnHeader2.Text = "sssss";
   // 
   // Form1
   // 
   this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
   this.ClientSize = new System.Drawing.Size(544, 413);
   this.Controls.Add(this.listView1);
   this.Controls.Add(this.progressBarSearch);
   this.Controls.Add(this.button1);
   this.Controls.Add(this.textBox1);
   this.Name = "Form1";
   this.Text = "Form1";
   this.ResumeLayout(false);

  }
  #endregion

  /// <summary>
  /// 应用程序的主入口点。
  /// </summary>
  [STAThread]
  static void Main() 
  {
   Application.Run(new Form1());
  }
  private void button1_Click(object sender, System.EventArgs e)
  {

   LanSearch();

  }
  /// <summary>
  /// 局域网搜索事件
 &n
分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • C#获取局域网MAC地址的简单实例
  • c# 获得局域网主机列表实例

相关文章

  • 2017-05-28C#中调用MySQL存储过程的方法
  • 2017-05-28C#.NET采用HTML模板发送电子邮件完整实例
  • 2017-05-28C#读写操作app.config中的数据应用介绍
  • 2017-05-28C# 判断字符串为空的几种办法
  • 2017-05-28WinForm中KeyDown,KeyPress和KeyUp的顺序与区别解析
  • 2017-05-28C# 调用API函数弹出映射网络驱动器对话框问题
  • 2017-05-28C#实现在前端网页弹出警告对话框(alert)的方法
  • 2017-05-28C#实现十五子游戏
  • 2017-05-28C# jpg缩略图函数代码
  • 2017-05-28C#仿密保卡功能的简单实现代码

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • C#可用于登录验证码的四位随机数生成方法
    • C#判断给定IP地址是否在指定范围内的方法
    • C#正则表达式匹配HTML中的图片路径,图片地址代码
    • C#通过Semaphore类控制线程队列的方法
    • C#基础入门之算法:交换
    • C#实现清空回收站的方法
    • C#防SQL注入代码的三种方法
    • C#向Word插入排版精良的TextBox
    • C#实现过滤html标签并保留a标签的方法
    • C#微信开发之自定义菜单管理

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有