char* strHost = www.baidu.com;
struct in_addr iaDestAddr; // Internet address structure
LPHOSTENT pHost; // Pointer to host entry structure
DWORD* dwAddress; // IP Address
iaDestAddr.s_addr = inet_addr(strHost);
if (INADDR_NONE == iaDestAddr.s_addr) // dealing with a name
{
pHost = gethostbyname(strHost);
}
else // dealing with an address
{
pHost = gethostbyaddr((const char*)&iaDestAddr, sizeof(struct in_addr),AF_INET);
}
if (NULL == pHost)
{
return FALSE;
}
dwAddress = (DWORD*)(*pHost->h_addr_list);