DhcpEnumSubnetClients

C# Signature:

[DllImport("dhcpsapi.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern uint DhcpEnumSubnetClients(
    string ServerIpAddress,
    uint SubnetAddress,
    ref uint ResumeHandle,
    uint PreferredMaximum,
    out IntPtr ClientInfo,
    ref uint ElementsRead,
    ref uint ElementsTotal);

VB Signature:

Declare Unicode Function DhcpEnumSubnetClients Lib "Dhcpsapi" (ByVal ServerIpAddress As String, ByVal SubnetAddress As Integer, ByRef ResumeHandle As Integer, ByVal PreferredMaximum As Integer, ByRef ClientInfo As IntPtr, ByRef ClientsRead As Integer, ByRef ClientsTotal As Integer) As Integer

Sample Code:

Imports System.Runtime.InteropServices

Sample Code:

Declare Unicode Function DhcpEnumSubnetClients Lib "dhcpsapi" (ByVal ServerIpAddress As String, ByVal SubnetAddress As Int32, ByRef ResumeHandle As IntPtr, ByVal PreferredMaximum As Integer, ByRef ClientInfo As IntPtr, ByRef ClientsRead As Integer, ByRef ClientsTotal As Integer) As Integer

    <StructLayout(LayoutKind.Sequential)> _
    Private Structure DHCP_IP_ARRAY
    Dim NumElements As Int32
    Dim Elements As IntPtr
    End Structure

    <StructLayout(LayoutKind.Sequential)> _
   Private Structure DHCP_CLIENT_INFO_ARRAY

    Dim NumElements As Integer
    Dim Clients As IntPtr

    End Structure

    <StructLayout(LayoutKind.Sequential)> _
Private Structure DHCP_CLIENT_INFO

    Dim ClientIpAddress As Int32
    Dim SubnetMask As Int32
    Dim ClientHardwareAddress As DHCP_BINARY_DATA

    <MarshalAs(UnmanagedType.LPWStr)> _
        Dim ClientName As String

    <MarshalAs(UnmanagedType.LPWStr)> _
    Dim ClientComment As String

    Dim ClientLeaseExpires As Date_Time
    Dim OwnerHost As DHCP_HOST_INFO

    End Structure

    <StructLayout(LayoutKind.Sequential)> _
    Private Structure DHCP_BINARY_DATA
    Dim DataLength As Int32
    Dim Data As IntPtr
    End Structure

    <StructLayout(LayoutKind.Sequential)> _
   Private Structure Date_Time

    <MarshalAs(UnmanagedType.U4)> _
    Dim dwLowDateTime As UInt32

    <MarshalAs(UnmanagedType.U4)> _
    Dim dwHighDateTime As UInt32

    End Structure

    <StructLayout(LayoutKind.Sequential)> _
Private Structure DHCP_HOST_INFO

    Dim IpAddress As Int32

    <MarshalAs(UnmanagedType.LPWStr)> _
    Dim NetBiosName As String

    <MarshalAs(UnmanagedType.LPWStr)> _
    Dim HostName As String

    End Structure

public sub ListSubnetClients()

        Dim Client_Array As DHCP_CLIENT_INFO_ARRAY
        Dim DHCP_Clients() As DHCP_CLIENT_INFO

Sample Code:

Sample Code:

Sample Code:

Sample Code:

Última actualización