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.Diagnostics; using System.IO; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { //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); } } }
Thursday, November 25, 2010
How to find the system is connected in LAN or not ?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment