C#WINFORM读取本机IP信息
发布网友
发布时间:2022-05-11 05:25
我来回答
共4个回答
热心网友
时间:2024-02-09 19:01
IPAddress[] ipAdd = Dns.GetHostAddresses("");
for (int i = 0; i < ipAdd.Length; i++)
{
IPAddress ipaddless = ipAdd[i];
if (ipaddless.AddressFamily == AddressFamily.InterNetwork)
{
args.IpAddress = ipaddless.ToString();
break;
}
}
热心网友
时间:2024-02-09 19:02
using System.Net;//申明
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = "";
IPHostEntry dnstoip = new IPHostEntry();
dnstoip = Dns.Resolve("mm56mm.3322.org");
for (int i = 0; i < dnstoip.AddressList.Length; i++)
{
textBox1.AppendText(textBox1.Text.ToString() + "对应的IP地址是" + dnstoip.AddressList[i].ToString());
}
}
热心网友
时间:2024-02-09 19:02
protected string GetIP() //获取本地IP
{
IPHostEntry ipHost = Dns.Resolve(Dns.GetHostName());
IPAddress ipAddr = ipHost.AddressList[0];
return ipAddr.ToString();
}
热心网友
时间:2024-02-09 19:03
http://wenku.baidu.com/view/9f5d26323968011ca3009169.html 网上到处都是,自己看看吧,其实就是调用C#内部的方法就行了