Thomas Tomiczek says
>Well, the original question was getting all the IP addresses a computer >posesses. >IMHO I am back to reading the registry information for the TCP Stack :-( no no no. I was just scaring you with the details of determining whether an an IP addr was valid or not, which is the advanced solution to the problem. If all you want to do is enum the current interfaces, the classic gethostname/gethostbyname pair is enough. Just discard the invalid stuff. One problem: invalid is hard to determine. I have attached a C++ method to do this This does not use DNS, AFAIK; it is entirely local to the system. IPHLPAPI? Only works properly on Win2K. On win98 SE it only really finds things like loopback adapters. Win2K also add SENS, BTW, lets you subscribe to lan coming/going events. /* I see that I set bNoHost here but dont act on it... */ DWORD OnNet::GetIPAddress() { char buffer[256]; BOOL bNoHost; DWORD address=0; WSADATA wsaData; if(0!=WSAStartup(MAKEWORD(1,1),&wsaData)) return 0; if(gethostname(buffer,sizeof(buffer))==0) { struct hostent * host=gethostbyname(buffer); if(!host) bNoHost=TRUE; else { if(host->h_length==sizeof(in_addr)) { for(int i=0;host->h_addr_list[i]!=NULL;i++) { in_addr *addr=(in_addr *)host->h_addr_list[i]; if(IsGoodIpAddress(addr->S_un.S_addr)) { address=addr->S_un.S_addr; break; } } } bNoHost=FALSE; } } WSACleanup (); return address; } You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.