GetBestInterface function (iphlpapi.h)
The GetBestInterface function retrieves the index of the interface that has the best route to the specified IPv4 address.
IPHLPAPI_DLL_LINKAGE DWORD GetBestInterface( IPAddr dwDestAddr, PDWORD pdwBestIfIndex );
The destination IPv4 address for which to retrieve the interface that has the best route, in the form of an IPAddr structure.
A pointer to a DWORD variable that receives the index of the interface that has the best route to the IPv4 address specified by dwDestAddr.
If the function succeeds, the return value is NO_ERROR.
If the function fails, the return value is one of the following error codes.
||The operation could not be completed.|
||An invalid parameter was passed to the function. This error is returned if a NULL pointer is passed in the pdwBestIfIndex parameter or if the pdwBestIfIndex points to memory that cannot be written.|
||The request is not supported. This error is returned if no IPv4 stack is on the local computer.|
||Use the FormatMessage function to obtain the message string for the returned error.|
The GetBestInterface function only works with IPv4 addresses. For use with IPv6 addresses, the GetBestInterfaceEx must be used.
On Windows Vista and later, the pdwBestIfIndex parameter is treated internally by IP Helper as a pointer to a NET_IFINDEX datatype.
|Minimum supported client||Windows 2000 Professional [desktop apps only]|
|Minimum supported server||Windows 2000 Server [desktop apps only]|