Share via


GetAdapterIndex (Compact 2013)

3/26/2014

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

Syntax

DWORD GetAdapterIndex(
  LPWSTR AdapterName, 
  PULONG IfIndex
);

Parameters

  • AdapterName
    [in] Pointer to the name of the adapter.
  • IfIndex
    [out] Pointer 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 disabling of the adapter is completed.

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

Header

iphlpapi.h

Library

Iphlpapi.lib

See Also

Reference

IP Helper Functions
IP_ADAPTER_INFO
NotifyAddrChange

Other Resources

IP Helper