如何使所有计算机列表连接到网络 [英] how to get the all computers list connected to network

查看:85
本文介绍了如何使所有计算机列表连接到网络的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在C#中获取所有连接到网络的计算机的IP地址列表.

how to get the all computers IP address list connected to network in C#

推荐答案

在CP本身的LAN网络上的许多文章中,这应该满足您的要求.需要:一个收集类,用于列出网络中所有计算机和服务器以及类别信息 [ ^ ]

请使用CP文章存储库,它有很多文章.一个简单的搜索可以为您提供更多所需的信息.

之前曾问过并回答过类似的问题:获取ipp地址通过局域网连接的所有计算机 [ ^ ]
Of many articles on LAN network here at CP itself, this one should meet your needs: A collection class for listing all the computers and servers in your network, with category information[^]

Please use CP articles repository, it has great many articles. A simple search can provide you much more in case you need.

Similar questions asked earlier and answered: get ipp address of all pcs connected via lan [^]


0)我在msdn上找到了此代码,但是如果您在公司/军事网络中,您可能无法获得所需的输出:

0) I found this code on msdn, but if you''re on a corporate/military network, you may not be able to get the desired output:

using System.Diagnostics;  
using System.IO;  
  
//Gets the machine names that are connected on LAN  
Process netUtility = new Process();  
netUtility.StartInfo.FileName = "net.exe";  
netUtility.StartInfo.CreateNoWindow = true;  
netUtility.StartInfo.Arguments = "view";  
netUtility.StartInfo.RedirectStandardOutput = true;  
netUtility.StartInfo.UseShellExecute = false;  
netUtility.StartInfo.RedirectStandardError = true;  
netUtility.Start();  
  
StreamReader streamReader = new StreamReader(netUtility.StandardOutput.BaseStream, netUtility.StandardOutput.CurrentEncoding);  
  
string line = "";  
  
while ((line = streamReader.ReadLine()) != null)  
{  
      if (line.StartsWith("\\"))  
      {  
           listBox1.Items.Add(line.Substring(2).Substring(0, line.Substring(2).IndexOf(" ")).ToUpper());  
      }  
}  
  
streamReader.Close();  
netUtility.WaitForExit(1000);  



1)您可以执行ping扫描,但是这将永远持续下去,并且如果在任何一个盒子上都启用了Windows防火墙,则它可能被配置为拒绝ICMP请求,并且您仍然被卡住-再次.

2)在第一个示例中使用net.exe,可以使用nMap.exe. Google的命令行参数.



1) You could do a ping sweep, but that would take forever, and if the Windows firewall is enabled on any of the boxes, it may be configured to refuse ICMP requests, and you''re stuck - again.

2) Insteat of using net.exe in the first example, you could use nMap.exe. Google for the commandline parameters.


如果所有都连接到Windows服务器-LDAP,我们可以获得该信息.希望它能解决.
If all connected to windows server - LDAP, we can get that information. Hope it solves.


这篇关于如何使所有计算机列表连接到网络的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆