DhcpV4EnumPolicies function (dhcpsapi.h)

The DhcpV4EnumPolicies function enumerates the policies configured on the DHCP Server.

Syntax

DWORD DHCP_API_FUNCTION DhcpV4EnumPolicies(
  [in, optional] LPWSTR              ServerIpAddress,
  [in, out]      LPDWORD             ResumeHandle,
  [in]           DWORD               PreferredMaximum,
  [in]           BOOL                fGlobalPolicy,
  [in]           DHCP_IP_ADDRESS     SubnetAddress,
  [out]          LPDHCP_POLICY_ARRAY *EnumInfo,
  [out]          DWORD               *ElementsRead,
  [out]          DWORD               *ElementsTotal
);

Parameters

[in, optional] ServerIpAddress

Pointer to a null-terminated Unicode string that represents the IP address or hostname of the DHCP server.

[in, out] ResumeHandle

Pointer to a DHCP_RESUME_HANDLE structure that identifies this enumeration for use in subsequent calls to this function.

Initially, this value should be zero on input. If successful, the returned value should be used for subsequent enumeration requests. For example, if PreferredMaximum is set to 100, and 200 policies are configured on the server, the resume handle can be used after the first 100 policies are retrieved to obtain the next 100 on a subsequent call.

[in] PreferredMaximum

The maximum number of policy structures to return in EnumInfo. If PreferredMaximum is greater than the number of remaining non-enumerated policies on the server, the remaining number of non-enumerated policies is returned.

[in] fGlobalPolicy

If TRUE the server level policy is enumerated. Otherwise, the scope level policy is enumerated.

[in] SubnetAddress

DHCP_IP_ADDRESS structure that contains the IPv4 subnet address of the policies to enumerate.

[out] EnumInfo

Pointer to a DHCP_POLICY_ARRAY structure that contains the policies available on the DHCP server. If no policies are configured, this value is NULL.

[out] ElementsRead

Pointer to a DWORD that specifies the number of policies returned in EnumInfo.

[out] ElementsTotal

Pointer to a DWORD that specifies the number of policies configured on the DHCP server that have not yet been enumerated.

Return value

If the function succeeds, it returns ERROR_SUCCESS.

If the function fails, it returns one of the following or an error code from DHCP Server Management API Error Codes.

Value Meaning
ERROR_MORE_DATA
There are more elements available to enumerate.
ERROR_NO_MORE_ITEMS
There are no more elements left to enumerate.

Remarks

EnumInfo should be free using DhcpRpcFreeMemory.

SubnetAddress must be in host-byte ordering.

Requirements

Requirement Value
Minimum supported client None supported
Minimum supported server Windows Server 2012 [desktop apps only]
Target Platform Windows
Header dhcpsapi.h
Library Dhcpsapi.lib
DLL Dhcpsapi.dll

See also

DhcpV4AddPolicyRange

DhcpV4CreatePolicy

DhcpV4DeletePolicy

DhcpV4GetPolicy

DhcpV4QueryPolicyEnforcement

DhcpV4RemovePolicyRange

DhcpV4SetPolicy

DhcpV4SetPolicyEnforcement