ConvertIpv4MaskToLength function (netioapi.h)

The ConvertIpv4MaskToLength function converts an IPv4 subnet mask to an IPv4 prefix length.

Syntax

IPHLPAPI_DLL_LINKAGE NETIOAPI_API ConvertIpv4MaskToLength(
  [in]  ULONG  Mask,
  [out] PUINT8 MaskLength
);

Parameters

[in] Mask

The IPv4 subnet mask.

[out] MaskLength

A pointer to a UINT8 value to hold the IPv4 prefix length, in bits, when the function returns successfully.

Return value

On success, ConvertIpv4MaskToLength returns NO_ERROR. Any nonzero return value indicates failure.

Error code Meaning
ERROR_INVALID_PARAMETER
One of the parameters was invalid. This error is returned if the Mask parameter was invalid.

Remarks

The ConvertIpv4MaskToLength function is available on Windows Vista and later.

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header netioapi.h (include Iphlpapi.h)
Library Iphlpapi.lib
DLL Iphlpapi.dll

See also

ConvertLengthToIpv4Mask