DhcpCreateOptionV5 function (dhcpsapi.h)

The DhcpCreateOptionV5 function creates a DHCP option.

Syntax

DWORD DhcpCreateOptionV5(
  [in]           LPWSTR         ServerIpAddress,
  [in]           DWORD          Flags,
  [in]           DHCP_OPTION_ID OptionId,
  [in, optional] LPWSTR         ClassName,
  [in, optional] LPWSTR         VendorName,
  [in]           LPDHCP_OPTION  OptionInfo
);

Parameters

[in] ServerIpAddress

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

[in] Flags

Flag value that indicates whether the option is for a specific or default vendor class.

Value Meaning
0x00000000
The option value is retrieved for a default vendor class.
DHCP_FLAGS_OPTION_IS_VENDOR
0x00000003
The option value is retrieved for a specific vendor class. The vendor name is supplied in VendorName.

[in] OptionId

DHCP_OPTION_ID value that contains the unique option ID number (also called an "option code") of the new option. Many of these option ID numbers are defined; a complete list of standard DHCP and BOOTP option codes can be found in DHCP Options and BOOTP Vendor Extensions.

[in, optional] ClassName

Unicode string that specifies the name of the DHCP class that will contain this option. This field is optional.

[in, optional] VendorName

Unicode string that contains a vendor name string if the class specified in ClassName is a vendor-specific class.

[in] OptionInfo

DHCP_OPTION structure that contains information describing the new DHCP option, including the name, an optional comment, and any related data items.

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_ACCESS_DENIED
This call was performed by a client who is not a member of the "DHCP Administrators" security group.
ERROR_DHCP_JET_ERROR
An error occurred while accessing the DHCP server's database.
ERROR_DHCP_OPTION_EXISTS
The specified option definition already exists in the DHCP server database.
ERROR_DHCP_CLASS_NOT_FOUND
The specified class name is unknown or incorrectly formed.

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