Platform SDK: Internet Protocol Helper

GetBestRoute

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

DWORD GetBestRoute(
  DWORD dwDestAddr,                // destination IP address
  DWORD dwSourceAddr,              // local source IP address
  PMIB_IPFORWARDROW pBestRoute     // best route for dest. addr.
);

Parameters

dwDestAddr
Specifies the destination IP address for which to obtain the best route.
dwSourceAddr
Specifies a 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. On successful return, this structure contains the best route for the IP address specified by dwDestAddr.

Return Values

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

  Windows NT/2000: Requires Windows 2000.
  Windows 95/98: Requires Windows 98.
  Header: Declared in Iphlpapi.h.
  Library: Use Iphlpapi.lib.

See Also

GetBestInterface, MIB_IPFORWARDROW