Circuit Negma

C++, C, VB.NET, PCB, Electronics, Circuit Design

IP Address Finder V1.0

Posted by Circuit Negma on May 13, 2012


Created By: Hussein Nosair

Sources:

1. http://csharp.net-informations.com/communications/csharp-ip-address.htm

2. http://www.daniweb.com/software-development/csharp/code/217169/find-ip-address

IP Address Finder V1.0

Download Link:

Name:
IPAddress1.rar

Path:
/

Size:
5.4KB (5550 bytes)

Modified:
2012-05-13 09:57:54

Uploaded:
2012-05-13 09:57:54

md5:
b4dcf8affc90bfe3897cc705f0986b5a

Shared:
Publicly Shared

URL:
http://www.adrive.com/public/ZCwq4A/IPAddress1.rar

Downloads:
0

Expires:
2012-05-27

Code:

   1:  using System;
   2:  //using System.Collections.Generic;
   3:  //using System.ComponentModel;
   4:  //using System.Data;
   5:  //using System.Drawing;
   6:  //using System.Linq;
   7:  //using System.Text;
   8:  using System.Windows.Forms;
   9:  using System.Net;
  10:  using System.Text.RegularExpressions;
  11:   
  12:   
  13:  namespace IPAddress1
  14:  {
  15:      public partial class Form1 : Form
  16:      {
  17:          public Form1()
  18:          {
  19:              InitializeComponent();
  20:              this.textBox1.Focus();
  21:   
  22:              //====================================
  23:              // Keys Detection Methods
  24:              //====================================
  25:              // Method 1
  26:              this.textBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(CheckEnterKey);
  27:   
  28:              // Method 2
  29:              //this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(CheckEnterKey);
  30:          }
  31:   
  32:          private void button1_Click(object sender, EventArgs e)
  33:          {
  34:              int tmpCount = 0;
  35:              IPHostEntry remoteHostName;
  36:              IPAddress[] ips;
  37:   
  38:              try
  39:              {
  40:                  remoteHostName = Dns.GetHostEntry(textBox1.Text);
  41:                  ips = remoteHostName.AddressList;
  42:   
  43:                  textBox2.AppendText("Host Name: " + textBox1.Text);
  44:                  textBox2.AppendText(Environment.NewLine);
  45:   
  46:                  System.Console.WriteLine(ips.Rank);
  47:                  
  48:                  foreach (IPAddress ipaddress in ips)
  49:                  {
  50:                      textBox2.AppendText("IP Address[" + tmpCount++ + "]: " + ipaddress.ToString());
  51:                      textBox2.AppendText(Environment.NewLine);
  52:                      System.Console.WriteLine("IP Address[" + tmpCount++ + "]: " + ipaddress.ToString());
  53:   
  54:                      System.Console.WriteLine("Hash Code: " + ipaddress.GetHashCode());
  55:                  }
  56:   
  57:              }
  58:              catch (System.Net.Sockets.SocketException ex)
  59:              {
  60:                  textBox2.Clear();
  61:                  textBox2.AppendText(ex.SocketErrorCode.ToString());
  62:                  Console.WriteLine(ex.SocketErrorCode.ToString());
  63:              }
  64:          }
  65:   
  66:          // Method 1
  67:          //-----------------------------------------------------------------------------
  68:          private void CheckEnterKey(object sender, System.Windows.Forms.KeyEventArgs e)
  69:          {
  70:              if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return)
  71:              {
  72:                  button1_Click(sender, e);
  73:              }
  74:          }
  75:   
  76:          // Method 2
  77:          //-----------------------------------------------------------------------------
  78:          /*private void CheckEnterKey(object sender, System.Windows.Forms.KeyEventArgs e)
  79:          {
  80:              if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return)
  81:              {
  82:                  button1_Click(sender, e);
  83:              }
  84:          }*/
  85:   
  86:          // Write to a file Method
  87:          //----------------------------------------------------------------------------
  88:          /*private void button1_Click(object sender, EventArgs e)
  89:          {
  90:              //
  91:              // This is the button labeled "Save" in the program.
  92:              //
  93:              File.WriteAllText("C:\\demo.txt", textBox1.Text);
  94:          }*/
  95:      }
  96:  }

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: