Windows API Reference
Retrieves the adapter address information for the local computer.
ULONG WINAPI GetAdaptersAddresses(
_In_ ULONG Family,
_In_ DWORD Flags,
_In_ PVOID pReserved,
_Inout_ PIP_ADAPTER_ADDRESSES pAdapterAddresses,
_Inout_ PULONG pOutBufLen
);
AF_UNSPECAF_INETAF_INET6GAA_FLAG_INCLUDE_PREFIXGAA_FLAG_SKIP_UNICASTGAA_FLAG_SKIP_ANYCASTGAA_FLAG_SKIP_MULTICASTGAA_FLAG_INCLUDE_DNS_SETTINGSGAA_FLAG_INCLUDE_GATEWAYSGAA_FLAG_INCLUDE_ALL_INTERFACESNULL.
IP_ADAPTER_ADDRESSES structures. Each structure describes an adapter.
If this buffer is not large enough, the function returns ERROR_BUFFER_OVERFLOW and sets the pOutBufLen parameter to the required buffer size.
pAdapterAddresses.
On output, if the buffer is not large enough, this parameter receives the required buffer size in bytes.
If the function succeeds, the return value is ERROR_SUCCESS.
If the buffer pointed to by pAdapterAddresses is not large enough to contain all the adapter address structures, the return value is ERROR_BUFFER_OVERFLOW.
If the function fails, the return value is one of the following error codes:
ERROR_INVALID_PARAMETERERROR_NOT_SUPPORTEDERROR_NO_DATAThe GetAdaptersAddresses function is used to retrieve adapter configuration information, including IP addresses, MAC addresses, gateway information, and DNS settings.
The function returns a linked list of IP_ADAPTER_ADDRESSES structures. You need to iterate through this list to access information for each adapter.
It's important to handle the case where the buffer is too small by checking the return value and resizing the buffer accordingly.
AF_INET. For IPv6, use AF_INET6. Use AF_UNSPEC to retrieve both IPv4 and IPv6 addresses.
| Minimum supported client | Windows Vista [desktop apps only] |
| Minimum supported server | Windows Server 2008 [desktop apps only] |
| Header | iphlpapi.h |
| Library | Iphlpapi.lib |
| DLL | Iphlpapi.dll |