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.
DhcpGetClientInfo (dhcpsapi)
.
C# Signature:
/// <summary>
/// The DhcpGetClientInfo function returns information about a specific DHCP client.
/// </summary>
/// <param name="ServerIpAddress">[in] Unicode string that specifies the IP address of the DHCP server.</param>
/// <param name="SearchInfo">[in] DHCP_SEARCH_INFO structure that contains the parameters for the search. </param>
/// <param name="ClientInfo">[out] Pointer to a DHCP_CLIENT_INFO structure that contains information describing the DHCP client that most closely matches the provided search parameters. If no client is found, this parameter will be null.</param>
/// <returns>This function returns ERROR_SUCCESS upon a successful call. Otherwise, it returns one of the DHCP Server Management API Error Codes.</returns>
''' <summary>
''' The DhcpGetClientInfo function returns information about a specific DHCP client.
''' </summary>
''' <param name="ServerIpAddress">[in] Unicode string that specifies the IP address of the DHCP server.
''' </param>
''' <param name="SearchInfo">[in] DHCP_SEARCH_INFO structure that contains the parameters for the search.
''' </param>
''' <param name="ClientInfo">[out] Pointer to a DHCP_CLIENT_INFO structure that contains information describing the DHCP client that most closely matches the provided search parameters. If no client is found, this parameter will be null.
''' </param>
''' <returns>This function returns ERROR_SUCCESS upon a successful call. Otherwise, it returns one of the DHCP Server Management API Error Codes.
''' </returns>
<DllImport("dhcpsapi.dll", SetLastError:=True, CharSet:=CharSet.Unicode)> _
Public Shared Function DhcpGetClientInfo( _
ByVal ServerIpAddress As String, _
ByRef SearchInfo As DHCP_SEARCH_INFO, _
ByRef ClientInfo As IntPtr) As UInt32
End Function
VB Signature and sample code added by BlUNt, adapted from C# Samples
Tips & Tricks:
Please add some!
Sample VB Code:
Public Function GetClientInfo(ByVal serverIP As String, ByVal clientIP As String)
Dim DHCPResult As UInt32 = 0
Try
Dim searchInfo As New DHCP_SEARCH_INFO
Dim searchInfoType As DHCP_SEARCH_INFO_TYPE = DHCP_SEARCH_INFO_TYPE.DhcpClientIpAddress
searchInfo.SearchType = searchInfoType
searchInfo.ClientIpAddress = ConvertIPAddress(clientIP)
Dim hClientInfo As IntPtr
If DHCPResult = ERROR_SUCCESS And Not hClientInfo = IntPtr.Zero Then
Dim clientInfo As DHCP_CLIENT_INFO = Marshal.PtrToStructure(hClientInfo, GetType(DHCP_CLIENT_INFO))
Return clientInfo
End If
Return Nothing
Catch ex As Exception
Console.WriteLine(ex.Message)
Return Nothing
End Try
End Function
Public Shared Function ConvertIPAddress(ByVal ipAddress As String) As UInt32
Dim dot As Char() = ".".ToCharArray()
Dim zero As Char() = "0".ToCharArray()
Dim Octets As String() = ipAddress.Split(dot(0))
Dim HexIP As String = ""
For Each Octet As String In Octets
HexIP += Convert.ToString(Convert.ToInt16(Octet), 16).PadLeft(2, zero(0))
Next
Return Convert.ToUInt32(HexIP, 16)
End Function
The DhcpGetClientInfo function returns information about a specific DHCP client.
9/24/2015 5:56:00 AM - -137.246.199.200
TODO - a short description
9/17/2018 1:57:26 AM - -195.226.121.69
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).