The function GetAdaptersInfo allows to retrieve the address information including netmask and default gateway for all adapters.
This function is deprecated since Windows Embedded Compact 7. The "Functionality To Use Instead" list the function GetAdaptersAddresses as a replacement. But this function doesn't report netmask and default gateway.
How can I get the netmask and the default gateway of the network adapters?
GetAdaptersAddressesreturns a linked list of IP_ADAPTER_ADDRESSES structs.Within each
IP_ADAPTER_ADDRESSES, theFirstUnitcastAddressfield points to a list of IP_ADAPTER_UNICAST_ADDRESSES structs.Within each
IP_ADAPTER_UNICAST_ADDRESSESthere is a field calledOnLinkPrefixLength, which specifies the netmask as the length, in bits, of the network part of the IP address. Note that this field is not documented for WEC2013 (it is for desktop Windows, though).To convert
OnLinkPrefixLengthto a ULONG mask, use ConvertLengthToIpv4Mask.Gateway addresses are provided through the
FirstGatewayAddressfield in eachIP_ADAPTER_ADDRESSESstruct.