I just collect it.
#include "winsock2.h" #pragma comment (lib, "ws2_32") const char * get_first_ip (void) {char szHostName [128]; const char * pszAddr = NULL; struct hostent * pHost; int i; WSADATA wsaData; WSAStartup (0x202, & wsadata); if (gethostname (SzhostName, 128) == 0) {phost = gethostByname (szhostname); for (i = 0; phost! = Null && phst-> h_addr_list [i]! = Null; i ) {/ * Processes each IP address * / pszaddr = inet_ntoa (* (Struct in_addr *) phost-> h_addr_list [i]); Break;}} wsacleanup (); Return Pszaddr;}