域名IP查寻的小工具
2007-05-05 18:30
183 查看
主要代码如下:
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("主机名: " + 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 button1_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
bool ck = checkip(textBox_input.Text);
if (!ck)
{
MessageBox.Show("您输入有误!");
textBox_input.Text = "";
}
else
{
iphost = Dns.GetHostEntry(textBox_input.Text);
listBox1.Items.Add(iphost.HostName);
}
}
private void textBox_input_MouseEnter(object sender, EventArgs e)
{
textBox_input.SelectAll();
}
}
}
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("主机名: " + 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 button1_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
bool ck = checkip(textBox_input.Text);
if (!ck)
{
MessageBox.Show("您输入有误!");
textBox_input.Text = "";
}
else
{
iphost = Dns.GetHostEntry(textBox_input.Text);
listBox1.Items.Add(iphost.HostName);
}
}
private void textBox_input_MouseEnter(object sender, EventArgs e)
{
textBox_input.SelectAll();
}
}
}
相关文章推荐
- 查询同一个ip对应多个域名的工具
- 黑蛋批量IP查域名工具 V1.0
- 发布一款域名监控小工具——Domain(IP)Watcher
- IP域名反查寻
- 生产环境中,通过域名映射ip切换工具SwitchHosts
- nginx 支持同一个ip 多个https域名
- lnmp环境里设置301跳转后用IP访问跳转到域名问题说明设置
- nginx servername配置域名网站可以正常登录,servername配置IP+Port却无法正常登录
- IIS tomcat共用80端口解决一个IP多个域名:使用Nginx反向代理方式使两者兼容
- 【Java】从域名得到ip
- 发现一个非常好的域名批量查询工具
- 使用Windows迁移工具迁移2003至2012R2 二、IP迁移
- 通过域名获得IP
- Linux下用C实现域名到IP的转换(域名解析)
- 渗透测试之IP和域名信息搜集验证
- Linux下显示IP地理位置信息的小工具-nali
- TCP/IP 实践之Ubuntu 16.04下安装网络流量分析工具 Wireshark
- IP 域名 DNS之间的区别
- Nginx设置禁止通过IP访问服务器并且只能通过指定域名访问