title: how to retrieve IP v6 subnet mask length
body: <p>I'm coding an application that has to get the network adapters configuration on a Windows 7 machine just like it's done in the Windows network adapters configuration panel:</p>
  
  <p><img src="https://i.stack.imgur.com/BkJKo.png" alt="enter image description here"></p>
  
  <p>So far I can get pretty much all the information I need from <code>NetworkInterface.GetAllNetworkInterfaces()</code> <strong>EXCEPT the subnet prefix length</strong>.</p>
  
  <p>I'm aware that it can be retrieved from the C++ struc <code>PMIB_UNICASTIPADDRESS_TABLE</code> via <code>OnLinkPrefixLength</code> but I'm trying to stay in .net.</p>
  
  <p>I also took a look at the <code>Win32_NetworkAdapterConfiguration</code> WMI class but it only seems to return the IP v4 subnet mask.</p>
  
  <p>I also know that some information (not the prefix length, as far as I know) are in the registry:</p>
  
  <pre><code>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\TCPIP6\Parameters\Interfaces\{CLSID}
  </code></pre>
  
  <p>I also used SysInternals ProcessMon to try to get anything usefull when saving the network adapter settings but found nothing...</p>
  
  <p>So, is there any clean .NET way to get this value? (getting it from the registry wouldn't be a problem)</p>
  
  <h2>EDIT: Gateways</h2>
  
  <p>This doesn't concern the actual question, but for those who need to retrieve the entire network adapter IPv6 configuration, the <code>IPInterfaceProperties.GatewayAdresses</code> property only supports the IPv4 gateways. As mentionned in the answer comments below, the only way to get the entire info until .NET framework 4.5 is to call WMI.</p>