DhcpSetOptionValue function (dhcpsapi.h)

The DhcpSetOptionValue function sets information for a specific option value on the DHCP server.

Syntax

DWORD DHCP_API_FUNCTION DhcpSetOptionValue(
  [in] DHCP_CONST WCHAR                  *ServerIpAddress,
  [in] DHCP_OPTION_ID                    OptionID,
  [in] DHCP_CONST DHCP_OPTION_SCOPE_INFO *ScopeInfo,
  [in] DHCP_CONST DHCP_OPTION_DATA       *OptionValue
);

Parameters

[in] ServerIpAddress

Pointer to a Unicode string that specifies the IP address or hostname of the DHCP server.

[in] OptionID

DHCP_OPTION_ID value that specifies the unique code for a DHCP option.

[in] ScopeInfo

Pointer to a DHCP_OPTION_SCOPE_INFO structure that contains information describing the level (default, server, scope, or IPv4 reservation) at which this option value will be set.

[in] OptionValue

Pointer to a DHCP_OPTION_DATA structure that contains the data value corresponding to the DHCP option code specified by OptionID.

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_OPTION_NOT_PRESENT
The specified option definition could not be found in the DHCP server database.
ERROR_DHCP_SUBNET_NOT_PRESENT
The specified IPv4 subnet does not exist on the DHCP server.
ERROR_DHCP_NOT_RESERVED_CLIENT
The specified DHCP client is not a reserved client.
ERROR_FILE_NOT_FOUND
The multicast scope specified in ScopeInfo was not found on the DHCP server.

Remarks

When this function is called for the first time, it creates the supplied option value in the DHCP server database. Otherwise, it modifies the option value for a specific option associated with the default user class and vendor class. These values can be set for the default, server, scope, or IPv4 reservation level on the DHCP server.

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_OPTION_DATA

DHCP_OPTION_SCOPE_INFO

DhcpSetOptionValueV5

DhcpSetOptionValues