title: How to read Windows default Gateway IP address in C++
body: <p>Can some body point me how to read the default windows gateway IP address in C++. I am able to read the list of all the IP addresses using GetAdaptersInfo() but not the default gateway IP address.</p>
  
  <pre><code>   GetAdaptersInfo( pAdapterInfo, &amp;BufferLength );
   // Iterate the network adapters and print their MAC address.
      while( pAdapterInfo )
      {           
          pAdapterInfo = pAdapterInfo-&gt;Next; // Get next adapter info
      }
  </code></pre>
  
  <p>Here is the code snippet and wondering which field gives me the default gateway. I can get the gateway of every IP address in the list but I need the default gateway IP address.</p>
  
  <p>The original reason for wanting this was to select the specific MAC address (from the bunch of MAC addresses) of the IP which has got the default gateway.  As we get multiple MAC addresses while iterating thru the list, we thought the best way is pick up the MAC address of the IP which has the default gateway.  We have since changed our minds, and will choose the wired connection MAC address.  But I am still curious to know how to get the default gateway instead of iterating thru all the adapters.</p>