网络中现有系统的列表 [英] List OF existing Systems in network
问题描述
我想用c#.net编写一个类似于netsupport的程序.
首先要想拥有所有现有的网络系统,并在列表视图中显示它.
我使用netapi32.dll,但看不到netapi32.dll的所有现有网络系统.
在我的网络中,系统是具有不同操作系统的工作组或域的成员.
现在,我希望所有现有的系统都可以打开.
请帮我:rose :: rose :: rose:
该程序的一个小例子:
soft1-172.16.0.1
soft2-172.16.0.2
soft3-172.16.0.3
I want write a program with c#.net which is similar to netsupport.
In the first laoding want have the all existing systems of network and show it in listview.
I use netapi32.dll but I don''t see all existing systems of network by netapi32.dll.
In my network, systems are member of workgroup or domain with different operation systems.
Now, I want have all existing systems that those turn on.
pleas, help me :rose::rose::rose:
A small example of the program:
soft1-172.16.0.1
soft2-172.16.0.2
soft3-172.16.0.3
推荐答案
尝试以下操作:
Try this:
using System;
using System.Diagnostics;
using System.IO;
using System.Collections.Generic;
class Program
{
static void Main ()
{
Process proc = new Process();
proc.StartInfo.FileName = "net.exe";
proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.Arguments = "view";
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.UseShellExecute = false;
proc.Start();
StreamReader sr = new StreamReader(proc.StandardOutput.BaseStream);
string line = "";
List<string> names = new List<string>();
while ((line = sr.ReadLine()) != null)
{
if (line.StartsWith(@"\\"))
names.Add(line.Substring(2).TrimEnd());
}
sr.Close();
proc.WaitForExit();
foreach(string name in names)
{
Console.WriteLine(name);
}
Console.ReadKey();
}
}
http://www.codeproject.com/KB/IP/ListNetworkComputers.aspx [ ^ ]
这篇关于网络中现有系统的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!