I have successfully found out how the use the Win32 NetBIOS API to see if a
workstation is online (corresponding to nbtstat -a computername).

But i can't seem to figure out how to programmatically find out the IP
corresponding to one of the workstation in the NBT cache that NBTSTAT -C
happily list. I currently get the IP information extracted by running
NBTSTAT.EXE but that is, as we know, extremly slow.

I guess you could use normal gethostbyname to find an IP but i'm not sure if
that IP can be trusted as well as it seems like sometimes DNS causes PING to
use and outdated IP while Nbtstat -a followed by nbtstat -c find the
one. Or can one assume that NetBIOS cache will be used first by
gethostbyname if the cache has the hostname?

Anyone know how nbtstat does it? Some unpublished API or even kernel stuff?
Or some other suggestions?