GetAdapterAddresses() provides subnet masks only for Vista and later.
When navigating through the unicast addresses pointed to by the FirstUnicastAddress field of the FirstUnicastAddress record, IP_ADAPTER_UNICAST_ADDRESS includes the OnLinkPrefixLength field. This field is not available on systems prior to Vista. This field is the length of the subnet mask in bits. For unicast IPv4 addresses, you can use ConvertLengthToIpv4Mask() to convert the OnLinkPrefixLength value to a subnet mask, which you can then use to mask a unicast IPv4 address as needed.
On systems prior to Vista, select GetIpAddrTable() for a list of available IPv4 interfaces. The MIB_IPADDRROW contains the dwAddr field for the IPv4 address, the dwMask field for the subnet mask, and the dwBCastAddr field for the broadcast address. You can scroll through this table by looking at each unicast IPv4 address specified by GetAdapterAddresses() , and then you will have associated subnet masks and broadcast IP addresses.
Remy Lebeau
source share