title: Resolve NetBIOS name on Windows 7
body: <p>According to this <a href="http://msdn.microsoft.com/en-us/library/bb870913(v=VS.85).aspx" rel="nofollow noreferrer">link</a>, NetBIOS is no longer supported starting from Windwos Vista.  Sure enough, I can no longer see any NetBIOS name from the network properties.</p>
  
  <p>However, when I am writing codes on my Windows 7, I still encounter NetBIOS names in many places. For example</p>
  
  <ol>
  <li>I can still use "MYDOMAIN\Harvey" to logon my machine, where I believe MYDOMAIN is a NetBIOS name.</li>
  <li>The environment variables COMPUTERNAME and USERDOMAIN are still NetBIOS names.  I am expecting to see a DNS names here</li>
  <li>My SQL Server instance names coming up from my SQL Server Management Studio is still something like MYMACHINE\Instance1.</li>
  </ol>
  
  <p>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 <a href="https://web.archive.org/web/1/http://articles.techrepublic%2ecom%2ecom/5100-10878_11-5034239.html" rel="nofollow noreferrer">NetBIOS name resolution</a> works but I am afraid this is no longer true in Windows 7.  At least there is no WINS server for me.  </p>
  
  <p>My last question is how do I do the NetBIOS name resolution programmatically, preferrably in C#.  I am okay to use PInvoke.</p>
  
  <p><strong><em>UDAPTE</em></strong></p>
  
  <p>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 <a href="http://msdn.microsoft.com/en-us/library/ms738524(v=vs.85).aspx" rel="nofollow noreferrer">gethostbyname() from ws2_32.dll</a></p>
  
  <p><a href="http://technet.microsoft.com/es-es/library/cc758517(WS.10).aspx" rel="nofollow noreferrer">Here</a>, it explains the gethostbyname() will do NetBIOS name resolution.  </p>
  
  <blockquote>
    <ol>
    <li>Check the local host name for a matching name.</li>
    <li>Check the Hosts file for a matching name entry.</li>
    <li>If a DNS server is configured, query it.</li>
    <li>If no match is found, attempt NetBIOS name-resolution.</li>
    </ol>
  </blockquote>
  
  <p>About the mystery of NetBIOS not supported in this <a href="http://msdn.microsoft.com/en-us/library/bb870903(v=VS.85).aspx" rel="nofollow noreferrer">link</a>, I think it just means the API is not supported.  <a href="https://serverfault.com/questions/224821/is-netbios-really-gone-on-windows">People in ServerFault</a> think that NetBIOS is still supported in Windows 7.</p>