GetAdaptersAddresses function (iphelper.h)

Retrieves the adapter address structures for all network adapters on the local computer.

Syntax
PULONG GetAdaptersAddresses(
  _In_     ULONG                 Family,
  _In_     ULONG                 Flags,
  _In_ PVOID                 pReserved,
  _Inout_ PIP_ADAPTER_ADDRESSES pAdapterAddresses,
  _Inout_ PULONG                pOutBufLen
);
Parameters
Parameter Description
Family

The address family for which to retrieve adapter information. Possible values are:

  • AF_UNSPEC: Returns information for all address families.
  • AF_INET: Returns information for IPv4 addresses.
  • AF_INET6: Returns information for IPv6 addresses.
Flags

Flags that specify how to retrieve adapter information. This parameter can be zero or one or more of the following values:

  • GAA_FLAG_INCLUDE_PREFIX: Include prefix information in the returned structures.
  • GAA_FLAG_SKIP_UNICAST: Skip unicast addresses.
  • GAA_FLAG_SKIP_ANYCAST: Skip anycast addresses.
  • GAA_FLAG_SKIP_MULTICAST: Skip multicast addresses.
  • GAA_FLAG_INCLUDE_WALK_ORDER: Include the walk order of the adapter in the returned structures.
  • GAA_FLAG_INCLUDE_ALL_INTERFACES: Include all interfaces, not just the ones that have IP addresses.
pReserved Reserved for future use. Must be NULL.
pAdapterAddresses A pointer to a buffer that will receive an array of IP_ADAPTER_ADDRESSES structures. If the buffer is not large enough, the function returns ERROR_BUFFER_OVERFLOW and sets the pOutBufLen parameter to the required buffer size.
pOutBufLen On input, the size of the buffer pointed to by pAdapterAddresses, in bytes. On output, if the buffer is not large enough, this parameter receives the required buffer size in bytes.
Return Value

If the function succeeds, the return value is NO_ERROR.

If the buffer pointed to by pAdapterAddresses is not large enough to contain the adapter information, the function returns ERROR_BUFFER_OVERFLOW and the value pointed to by the pOutBufLen parameter is set to the required buffer size.

If the function fails, the return value is one of the following error codes:

Remarks

This function is used to retrieve information about network adapters on the local computer.

The caller must initialize the pOutBufLen parameter to the size of the buffer pointed to by pAdapterAddresses.

The returned adapter address structures are linked together in a linked list through their Next members.

For a detailed example of using this function, see the Network Sample Code.

Requirements
Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header iphelper.h
Library Iphlpapi.lib
DLL Iphlpapi.dll
See Also