Domain Name IP Lookup gadgets

Source: Internet
Author: User

MainCodeAs follows:
Using system;
Using system. Collections. Generic;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. text;
Using system. Windows. forms;
Using system. net;

Namespace ip2domain
{
Public partial class form1: Form
{
Public form1 ()
{
Initializecomponent ();
Centertoscreen ();
}

Public bool checkip (string IP)
{

String [] vlist = IP. Split ('.');

If (vlist. length! = 4) return false;

For (Int J = 0; j <vlist. length; j ++)
{

Int I;

If (! Int. tryparse (vlist [J], out I ))
Return false;

If (I <0) | (I> 254 ))
Return false;

If (I = 0) & (j = 0 ))
Return false;

}

Return true;

}

Iphostentry iphost;

Private void button_ OK _click (Object sender, eventargs E)
{
Try
{
If (textbox_input.text! = "")
{

Listbox1.items. Clear ();
Iphost = DNS. gethostentry (textbox_input.text );
String hostname = iphost. hostname;
Listbox1.items. Add ("Host Name:" + hostname );
Listbox1.items. Add ("");
For (INT I = 0; I <iphost. Addresslist. length; I ++)
{
Ipendpoint ipend = new ipendpoint (iphost. Addresslist [I], 0 );
IPaddress IP = ipend. address;
String IPS = IP. tostring ();
If (IPS! = "")
{
Listbox1.items. Add (IP );
Listbox1.items. Add ("");
}
Else
{
MessageBox. Show ("no IP infomation! ");
}
}
}

// else
// {
// MessageBox. Show ("There must be some wrong! Please retry! ");

// Textbox_input.text = "";
//}
}
Catch (exception ex)
{
MessageBox. Show (ex. Message );
Textbox_input.text = "";
}

}

Private void button#click (Object sender, eventargs E)
{
Listbox1.items. Clear ();
Bool ck = checkip (textbox_input.text );
If (! CK)
{
MessageBox. Show ("your input is incorrect! ");
Textbox_input.text = "";
}
Else
{
Iphost = DNS. gethostentry (textbox_input.text );
Listbox1.items. Add (iphost. hostname );
}
}

private void textbox_input_mouseenter (Object sender, eventargs e)
{< br> textbox_input.selectall ();
}< BR >}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.