DhcpV4GetPolicy function (dhcpsapi.h)

The DhcpV4GetPolicy function retrieves a policy from the DHCP Server.

Syntax

DWORD DHCP_API_FUNCTION DhcpV4GetPolicy(
  [in, optional] LPWSTR          ServerIpAddress,
  [in]           BOOL            fGlobalPolicy,
  [in]           DHCP_IP_ADDRESS SubnetAddress,
  [in]           LPWSTR          PolicyName,
  [out]          LPDHCP_POLICY   *Policy
);

Parameters

[in, optional] ServerIpAddress

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

[in] fGlobalPolicy

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

[in] SubnetAddress

DHCP_IP_ADDRESS structure that contains the IPv4 subnet address of the policy to retrieve.

[in] PolicyName

A null-terminated Unicode string that represents the name of the policy to retrieve.

[out] Policy

Pointer to a DHCP_POLICY structure that contains the parameters of the policy requested in PolicyName.

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_INVALID_PARAMETER
One or more of the parameters were invalid.
ERROR_DHCP_SUBNET_NOT_PRESENT
The specified IPv4 subnet does not exist.
ERROR_DHCP_POLICY_NOT_FOUND
The DHCP server policy was not found.

Remarks

Policy should be free using DhcpRpcFreeMemory.

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

DhcpV4EnumPolicies

DhcpV4QueryPolicyEnforcement

DhcpV4RemovePolicyRange

DhcpV4SetPolicy

DhcpV4SetPolicyEnforcement