18,356
社区成员
发帖
与我相关
我的任务
分享
#include<winsock2.h>
#pragma comment(lib, "Ws2_32.lib")
WORD wVersionRequested;
WSADATA wsaData;
char name[255];
CString ip;
PHOSTENT hostinfo;
wVersionRequested = MAKEWORD( 2, 0 );
sprintf(name,"%s","http://www.sohu.com");
if ( WSAStartup( wVersionRequested, &wsaData ) == 0 )
{
if((hostinfo = gethostbyname("http://www.sohu.com")) != NULL)
{
ip = inet_ntoa (*(struct in_addr *)*hostinfo->h_addr_list);
}
WSACleanup( );
}
MessageBox(ip);