header image
Home
NinethSense
My Favorites
Blog
Reach Me
 
My Microsoft
My OpenSource
My Electronics
My Misc Tech
My Project Management
 


Home arrow My Microsoft arrow Microsoft arrow LanScan
LanScan PDF Print
Written by Praveen V Nair   
Apr 30, 2007 at 05:16 AM

Author: PraVeeN - Microsoft MVP

LanScan is a utility for cheking which computer is ON and which computer is OFF now.

This application is developed with Dotnet 2.0 with C# .

 

LanScan Utility

 

Well..., this is the heart code:

private void ThreadProc()
{
pictureBox1.Visible =
true;
button1.Enabled =
false;
label1.Visible =
true;
Ping p = new Ping();
PingReply pr = null;
System.Net.
IPAddress ipaddress = null;
string hostname = string.Empty;

for (int i = 1; i < 255; i++)
{
label1.Text =
"Checking " + i.ToString() + "/255 Machines";
Application.DoEvents();
ipaddress = System.Net.
IPAddress.Parse("192.168.0." + i.ToString());
pr = p.Send(ipaddress, 1);
if (pr.Status.ToString() == "Success")
{
hostname = System.Net.
Dns.GetHostByAddress(ipaddress).HostName.ToString();
ListViewItem lv = listView1.Items.Add(ipaddress.ToString());
lv.SubItems.Add(hostname);
lv.SubItems.Add(
"On");
lv.ForeColor =
Color.DarkGreen;
lv = listView2.Items.Add(ipaddress.ToString());
lv.SubItems.Add(hostname);
lv.SubItems.Add(
"On");
lv.ForeColor =
Color.DarkGreen;
}
else
{
ListViewItem lv = listView1.Items.Add(ipaddress.ToString());
lv.SubItems.Add(
"");
lv.SubItems.Add(
"Off");
lv.ForeColor =
Color.Red;
lv = listView3.Items.Add(ipaddress.ToString());
lv.SubItems.Add(
"");
lv.SubItems.Add(
"Off");
lv.ForeColor =
Color.Red;
}
label2.Text =
"Total " + listView2.Items.Count + " Machines ON";
}
label1.Visible =
false;
button1.Enabled =
true;
pictureBox1.Visible =
false;
}

 


Download Executable
Download Source

 

 

<Previous   Next>
Microsoft MVP
Trivandrum Microsoft Users Group Forum
MSDN
ASP.net forums
  PHP Kerala Forums
PIT Solutions 



The CodeProject Microsoft Developer Network Official ASP.NET Forums Microsoft .NET Framework Community Microsoft Most Valuable Professional Kidoos.net forums Microsoft Visual Studio Developer Home Professional Information Technology Solutions Microsoft Research Home Trivandrum Microsoft Users Group Community Website