我想要通过输入ip地址 获取那台机子的信息啊
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public void button1_Click(object sender, EventArgs e)
{
string ip = this.textBox1.Text;
IPHostEntry hostinfo = Dns.GetHostByName("4c02e5f6f6af413");
textBox1.Text = Convert.ToString(hostinfo);
bool blnTest = false;
bool _Result = true;
Regex regex = new Regex("^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$");
blnTest = regex.IsMatch(textBox1.Text);
if (blnTest == true)
{
string[] strTemp = this.textBox1.Text.Split(new char[] { '.' }); // textBox1.Text.Split(new char[] { '.' });
for (int i = 0; i < strTemp.Length; i++)
{
if (Convert.ToInt32(strTemp[i]) > 255)
{ //大于255则提示,不符合IP格式
MessageBox.Show("不符合IP格式");
_Result = false;
}
}
}
else
{
//输入非数字则提示,不符合IP格式
MessageBox.Show("不符合IP格式");
_Result = false;
}
host.Items.Add(textBox1.Text);
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
}
}