jwalto1
June 17th, 2004, 11:41 AM
Hi All,
Currently I'm using the function below to translate IP's to friendly names. However, DNS is giving either bad or stale results (confirmed with nslookup). I suspect there is trouble with the reverse entries. nbtstat gives correct results (so the host is registering properly with WINS). Is there a way to programically use WINS or NetBIOS to resolve IPs to hostnames? A function will be fine - I'll work out the details.
Thanks,
Jeff
BOOL GetNameFromIPAddress( DWORD dwIP, TCHAR* pszHostName ) {
HOSTENT *p = NULL;
p = gethostbyaddr((const char*)&dwIP, 4, AF_INET);
if( p && p->h_name ) {
#ifdef UNICODE
{
USES_CONVERSION;
wcscpy( ppszHostName, A2W( p->h_name) );
}
#else
{
_tcscpy( ppszHostName, p->h_name);
}
#endif
return TRUE;
} else {
return FALSE;
}
}
Currently I'm using the function below to translate IP's to friendly names. However, DNS is giving either bad or stale results (confirmed with nslookup). I suspect there is trouble with the reverse entries. nbtstat gives correct results (so the host is registering properly with WINS). Is there a way to programically use WINS or NetBIOS to resolve IPs to hostnames? A function will be fine - I'll work out the details.
Thanks,
Jeff
BOOL GetNameFromIPAddress( DWORD dwIP, TCHAR* pszHostName ) {
HOSTENT *p = NULL;
p = gethostbyaddr((const char*)&dwIP, 4, AF_INET);
if( p && p->h_name ) {
#ifdef UNICODE
{
USES_CONVERSION;
wcscpy( ppszHostName, A2W( p->h_name) );
}
#else
{
_tcscpy( ppszHostName, p->h_name);
}
#endif
return TRUE;
} else {
return FALSE;
}
}