GetAdapterIndex function (iphlpapi.h)

The GetAdapterIndex function obtains the index of an adapter, given its name.

Syntax

IPHLPAPI_DLL_LINKAGE DWORD GetAdapterIndex(
  [in]      LPWSTR AdapterName,
  [in, out] PULONG IfIndex
);

Parameters

[in] AdapterName

A pointer to a Unicode string that specifies the name of the adapter.

[in, out] IfIndex

A pointer to a ULONG variable that points to the index of the adapter.

Return value

If the function succeeds, the return value is NO_ERROR.

If the function fails, use FormatMessage to obtain the message string for the returned error.

Remarks

Until an adapter is fully disabled, the GetAdapterIndex function reports the adapter as present. For example, the NotifyAddrChange function may indicate a recently disabled adapter's IP address is removed, but GetAdapterIndex continues to report an adapter index until the process of disabling the adapter is complete.

When one or more adapters are present on the system, GetAdapterIndex returns ERROR_DEV_NOT_EXIST when the adapter being queried does not exist. When no adapters are present, the GetAdapterIndex function returns ERROR_NO_DATA.

The adapter index may change when an adapter is disabled and then enabled, or under other circumstances, and should not be considered persistent.

Requirements

Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header iphlpapi.h
Library Iphlpapi.lib
DLL Iphlpapi.dll

See also

GetAdaptersInfo

IP Helper Function Reference

IP Helper Start Page

IP_ADAPTER_INFO

MprConfigGetFriendlyName

MprConfigGetGuidName

NotifyAddrChange