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_UNSPEC
AF_INET
AF_INET6
GAA_FLAG_INCLUDE_PREFIX
GAA_FLAG_SKIP_UNICAST
GAA_FLAG_SKIP_ANYCAST
GAA_FLAG_SKIP_MULTICAST
GAA_FLAG_INCLUDE_DNS_SETTINGS
GAA_FLAG_INCLUDE_GATEWAYS
GAA_FLAG_INCLUDE_ALL_INTERFACES
NULL
.
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_PARAMETER
ERROR_NOT_SUPPORTED
ERROR_NO_DATA
The 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 |