DhcpEnumOptions function (dhcpsapi.h)

The DhcpEnumOptions function returns an enumerated set of options stored on the DHCPv4 server.

Syntax

DWORD DHCP_API_FUNCTION DhcpEnumOptions(
  [in]      DHCP_CONST WCHAR    *ServerIpAddress,
  [in, out] DHCP_RESUME_HANDLE  *ResumeHandle,
  [in]      DWORD               PreferredMaximum,
  [out]     LPDHCP_OPTION_ARRAY *Options,
  [out]     DWORD               *OptionsRead,
  [out]     DWORD               *OptionsTotal
);

Parameters

[in] ServerIpAddress

Pointer to a Unicode string that specifies the IPv4 address of the DHCP server.

[in, out] ResumeHandle

Pointer to a DHCP_RESUME_HANDLE value that identifies the enumeration operation. Initially, this value should be zero, with a successful call returning the handle value used for subsequent enumeration requests. For example, if PreferredMaximum is set to 1000 bytes, and 2000 bytes worth of options are stored on the server, the resume handle can be used after the first 1000 bytes are retrieved to obtain the next 1000 on a subsequent call, and so forth.

The presence of additional enumerable data is indicated when this function returns ERROR_MORE_DATA. If no additional enumerable data is available on the DHCPv4 server, ERROR_NO_MORE_ITEMS is returned.

[in] PreferredMaximum

Specifies the preferred maximum number of bytes of options to return. If the number of remaining unenumerated options (in bytes) is less than this value, then that amount will be returned.

To retrieve all the option definitions for the default user and vendor class, set this parameter to 0xFFFFFFFF.

[out] Options

Pointer to a DHCP_OPTION_ARRAY structure containing the returned options. If there are no options available on the DHCPv4 server, this parameter will return null.

[out] OptionsRead

Pointer to a DWORD value that specifies the number of options returned in Options.

[out] OptionsTotal

Pointer to a DWORD value that specifies the total number of remaining options stored 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_MORE_DATA
There are more elements available to enumerate.
ERROR_NO_MORE_ITEMS
There are no more elements left to enumerate.

Remarks

The caller of this function must free the memory pointed to by Options after the call completes.

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_ARRAY

DHCP_RESUME_HANDLE

DhcpCreateOption

DhcpRemoveOption