GetBestRoute function (iphlpapi.h)

The GetBestRoute function retrieves the best route to the specified destination IP address.

Syntax

IPHLPAPI_DLL_LINKAGE DWORD GetBestRoute(
  DWORD             dwDestAddr,
  DWORD             dwSourceAddr,
  PMIB_IPFORWARDROW pBestRoute
);

Parameters

dwDestAddr

Destination IP address for which to obtain the best route.

dwSourceAddr

Source IP address. This IP address corresponds to an interface on the local computer. If multiple best routes to the destination address exist, the function selects the route that uses this interface.

This parameter is optional. The caller may specify zero for this parameter.

pBestRoute

Pointer to a MIB_IPFORWARDROW structure containing the best route for the IP address specified by dwDestAddr.

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.

Requirements

   
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

GetBestInterface

IP Helper Function Reference

IP Helper Start Page

MIB_IPFORWARDROW