如何找到我的公共IP [英] How to find my public ip

查看:150
本文介绍了如何找到我的公共IP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好b $ b

我想使用MFC找到我的公共IP,我可以从 www看到.whatismyip.com / [ ^ ]

有没有办法以编程方式找到它?

提前谢谢

解决方案

是的 - 谷歌会告诉你: http://www.google。 co.uk/search?sourceid=chrome&ie=UTF-8&q=find+ip+c%2B%2B+mfc [ ^ ]



最受欢迎的是C ++论坛中的那个问题... http://www.codeproject.com/Messages/3033351/How-to-get-IP-Address-of-the-system-using-MFC。 ASPX [< a href =http://www.codeproject.com/Messages/3033351/How-to-get-IP-Address-of-the-system-using-MFC.aspx\"target =_ blanktitle =新窗口> ^ ]


您好您可以按照以下步骤以编程方式查找公共IP



公共字符串GetLanIPAddress ()

{

//获取主机名

string stringHostName = Dns.GetHostName();

//获取IP主机条目

IPHostEntry ipHostEntries = Dns.GetHostEntry(stringHostName);

//从IP主机条目地址列表中获取IP地址

IPAddress [] arrIpAddress = ipHostEntries.AddressList;

return arrIpAddress [arrIpAddress.Length - 1] .ToString();

}



//获取Lan Ip地址

string strLanIpAddress = GetLanIPAddress();



如果你想检查公共IP地址,你可以访问这个网站

Ip-details.com

Hi
I want to find my public ip using MFC,which i can see from the www.whatismyip.com/[^]
is there a way to find it programmatically?
Thanks in advance

解决方案

Yes - as google would have told you: http://www.google.co.uk/search?sourceid=chrome&ie=UTF-8&q=find+ip+c%2B%2B+mfc[^]

The top hit is that question in the C++ forum... http://www.codeproject.com/Messages/3033351/How-to-get-IP-Address-of-the-system-using-MFC.aspx[^]


Hi you can follow the below steps to find public ip programmatically

public string GetLanIPAddress()
{
//Get the Host Name
string stringHostName = Dns.GetHostName();
//Get The Ip Host Entry
IPHostEntry ipHostEntries = Dns.GetHostEntry(stringHostName);
//Get The Ip Address From The Ip Host Entry Address List
IPAddress[] arrIpAddress = ipHostEntries.AddressList;
return arrIpAddress[arrIpAddress.Length - 1].ToString();
}

//Get The Lan Ip Address
string strLanIpAddress = GetLanIPAddress();

If you want to check public ip address you can visit this site
Ip-details.com


这篇关于如何找到我的公共IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆