GetAdapterIndex function (iphlpapi.h)
The GetAdapterIndex function obtains the index of an adapter, given its name.
IPHLPAPI_DLL_LINKAGE DWORD GetAdapterIndex( LPWSTR AdapterName, PULONG IfIndex );
A pointer to a Unicode string that specifies the name of the adapter.
A pointer to a ULONG variable that points to the index of the adapter.
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.
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.
|Minimum supported client||Windows 2000 Professional [desktop apps only]|
|Minimum supported server||Windows 2000 Server [desktop apps only]|