Partager via


SetIpStatistics (Compact 2013)

3/26/2014

This function toggles IP forwarding on or off and sets the default Time to Live (TTL) value for the local device.

Syntax

DWORD SetIpStatistics(
  PMIB_IPSTATS pIpStats 
);

Parameters

  • pIpStats
    [in] Pointer to a MIB_IPSTATS structure. The caller should set the dwForwarding and dwDefaultTTL members of this structure to the new values. To keep one of the members at its current value, use MIB_USE_CURRENT_TTL or MIB_USE_CURRENT_FORWARDING.

Return Value

If the function succeeds, the return value is NO_ERROR.

If the function fails, the return value is one of the following error codes.

Return code

Description

ERROR_ACCESS_DENIED

Access is denied.

ERROR_INVALID_PARAMETER

An invalid parameter was passed to the function. This error is returned if a NULL pointer is passed in the pIpStats parameter. This error is also returned if the dwForwarding member in the MIB_IPSTATS structure pointed to by the pIpStats parameter contains a value other than MIB_IP_NOT_FORWARDING, MIB_IP_FORWARDING, or MIB_USE_CURRENT_FORWARDING.

Other

Use FormatMessage to obtain the message string for the returned error.

Remarks

To set only the default TTL, the caller can also use the SetIpTTL function.

Requirements

Header

iphlpapi.h

Library

Iphlpapi.lib

See Also

Reference

IP Helper Functions
MIB_IPSTATS
SetIpTTL
SetIpStatisticsEx

Other Resources

IP Helper