您的位置:首页 > 其它

VC获得Host的IP和名称

2008-07-07 21:44 309 查看
void GetIP()

{
char szHostName[128];
char szT[20];
if( gethostname(szHostName, 128) == 0 )
{
// Get host adresses
m_HostName.SetWindowText(szHostName);
struct hostent * pHost;
int i;
pHost = gethostbyname(szHostName);
for( i = 0; pHost!= NULL && pHost->h_addr_list[i]!= NULL; i++ )
{
char str[100];
char addr[20];
int j;
LPCSTR psz=inet_ntoa (*(struct in_addr *)pHost->h_addr_list[i]);
m_IPAddr.AddString(psz);
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: