According to this link, NetBIOS is no longer supported starting from Windwos Vista. Sure enough, I can no longer see any NetBIOS name from the network properties.
However, when I am writing codes on my Windows 7, I still encounter NetBIOS names in many places. For example
I am guessing Microsoft still maintains some pieces of it for backward compatibility. I want to understand how Windows 7 going to resolve the NetBIOS name to an IP address. I found this article explaining how the NetBIOS name resolution works but I am afraid this is no longer true in Windows 7. At least there is no WINS server for me.
My last question is how do I do the NetBIOS name resolution programmatically, preferrably in C#. I am okay to use PInvoke.
UDAPTE
Tridus was right. I can use System.Net.Dns.GetHostAddresses("hostname") to resolve NetBIOS name. I used reflector to see what's happening under the hood. It is calling gethostbyname() from ws2_32.dll
Here, it explains the gethostbyname() will do NetBIOS name resolution.
- Check the local host name for a matching name.
- Check the Hosts file for a matching name entry.
- If a DNS server is configured, query it.
- If no match is found, attempt NetBIOS name-resolution.
About the mystery of NetBIOS not supported in this link, I think it just means the API is not supported. People in ServerFault think that NetBIOS is still supported in Windows 7.
Name Resolution Methods The three standard ways of resolving NetBIOS names to IP addresses are through a local broadcast, using the local cache, or by using a NetBIOS name server. With a local broadcast, a broadcast is sent out on the network requesting the IP address of a specific host.
In Windows 7, the default NetBIOS setting is to use the NetBIOS setting provided via DHCP. If a Windows 7 computer uses a static IPv4 address, it will automatically use NetBIOS over TCP/IP.
NetBIOS itself as the old protocol might not be supported, but SMB/CIFS still is and that's why \hostname for filesharing and such still works.
As for how to resolve a name, I was able to do this:
System.Net.Dns.GetHostAddresses("hostname")
I'm on a domain so it may be simply appending a DNS suffix and doing a DNS lookup, but it worked for me. Give it a try. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With