#include "winsock2.h" …… char S[64]; HOSTENT FAR *pHost; AnsiString LocalAddress, LocalName;//IP,name gethostname(S, 64); LocalName = AnsiString(S); pHost = gethostbyname(S); LocalAddress = inet_ntoa(*(struct in_addr*)pHost->h_addr_list[0]);