Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than dhcpsapi, prefix the name with the module name and a period.
public static List<DhcpIpAddress> GetReservedIps(DhcpServer server, DhcpIpAddress subnet) {
List<DhcpIpAddress> reservations = new List<DhcpIpAddress>();
uint resumeHandle = 0;
uint read = 0, total = 0;
IntPtr enumInfo = IntPtr.Zero;
uint result = 0;
do {
result = NativeMethods.DhcpEnumSubnetElementsV5(server.Address, subnet, NativeMethods.DHCP_SUBNET_ELEMENT_TYPE.DhcpReservedIps, ref resumeHandle, 1000, ref enumInfo, ref read, ref total);
if (result == NativeMethods.ERROR_NO_MORE_ITEMS) break;
if ((result != NativeMethods.ERROR_SUCCESS && result != NativeMethods.ERROR_MORE_DATA) || enumInfo == IntPtr.Zero)
throw new DhcpException(result, "DhcpEnumSubnetElementsV5");
NativeMethods.DHCP_SUBNET_ELEMENT_INFO_ARRAY_V5 data;
data = (NativeMethods.DHCP_SUBNET_ELEMENT_INFO_ARRAY_V5) Marshal.PtrToStructure(enumInfo, typeof(NativeMethods.DHCP_SUBNET_ELEMENT_INFO_ARRAY_V5));
for (int i = 0; i < data.NumElements; i++) {
IntPtr p = (IntPtr) ((int) data.Elements + (i * Marshal.SizeOf(typeof(NativeMethods.DHCP_SUBNET_ELEMENT_DATA_V5))));
NativeMethods.DHCP_SUBNET_ELEMENT_DATA_V5 element;
element = (NativeMethods.DHCP_SUBNET_ELEMENT_DATA_V5) Marshal.PtrToStructure(p, typeof(NativeMethods.DHCP_SUBNET_ELEMENT_DATA_V5));
reservations.Add(new DhcpIpAddress(reservation.ReservedIpAddress));
}
}
}
while (result == NativeMethods.ERROR_MORE_DATA);
return reservations;
}
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).