DhcpRemoveSubnetElement function (dhcpsapi.h)

The DhcpRemoveSubnetElement function removes an IPv4 subnet element from an IPv4 subnet defined on the DHCPv4 server.

Syntax

DWORD DHCP_API_FUNCTION DhcpRemoveSubnetElement(
  [in] DHCP_CONST WCHAR                    *ServerIpAddress,
  [in] DHCP_IP_ADDRESS                     SubnetAddress,
  [in] DHCP_CONST DHCP_SUBNET_ELEMENT_DATA *RemoveElementInfo,
  [in] DHCP_FORCE_FLAG                     ForceFlag
);

Parameters

[in] ServerIpAddress

Unicode string that specifies the IP address or hostname of the DHCPv4 server.

[in] SubnetAddress

DHCP_IP_ADDRESS value that specifies the IPv4 address of the subnet gateway from which elements are to be removed.

[in] RemoveElementInfo

DHCP_SUBNET_ELEMENT_DATA structure that contains information used to find the element that will be removed from subnet specified in SubnetAddress.

[in] ForceFlag

DHCP_FORCE_FLAG enumeration value that indicates whether or not the clients affected by the removal of the subnet element should also be deleted.

Note  If the flag is set to DhcpNoForce and this subnet has served an IPv4 address to DHCPv4/BOOTP clients, the IPv4 range is not deleted; conversely, if the flag is set to DhcpFullForce, the IPv4 range is deleted along with the DHCPv4 client lease record on the DHCPv4 server.
 

Return value

This function returns ERROR_SUCCESS upon a successful call. Otherwise, it returns one of the DHCP Server Management API Error Codes.

Return code Description
ERROR_DHCP_JET_ERROR
An error occurred while accessing the DHCP server database.
ERROR_DHCP_SUBNET_NOT_PRESENT
The specified IPv4 subnet is not defined on the DHCP server.
ERROR_DHCP_RESERVED_CLIENT
The specified DHCP client is a reserved client.
ERROR_DHCP_INVALID_RANGE
The specified IPv4 address range either overlaps an existing IPv4 address range, or is invalid.
ERROR_DHCP_ELEMENT_CANT_REMOVE
At least one multicast IPv4 address has been leased out to a MADCAP client.

Requirements

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

See also

DHCP_FORCE_FLAG

DHCP_SUBNET_ELEMENT_DATA

DhcpAddSubnetElement