Win32 API 日本語リファレンス
ホームNetworkManagement.Dhcp › DhcpV4GetClientInfoEx

DhcpV4GetClientInfoEx

関数
検索条件に一致するIPv4クライアント情報を拡張形式で取得する。
DLLDHCPSAPI.dll呼出規約winapi

シグネチャ

// DHCPSAPI.dll
#include <windows.h>

DWORD DhcpV4GetClientInfoEx(
    LPCWSTR ServerIpAddress,   // optional
    const DHCP_SEARCH_INFO* SearchInfo,
    DHCP_CLIENT_INFO_EX** ClientInfo
);

パラメーター

名前方向
ServerIpAddressLPCWSTRinoptional
SearchInfoDHCP_SEARCH_INFO*in
ClientInfoDHCP_CLIENT_INFO_EX**out

戻り値の型: DWORD

各言語での呼び出し定義

// DHCPSAPI.dll
#include <windows.h>

DWORD DhcpV4GetClientInfoEx(
    LPCWSTR ServerIpAddress,   // optional
    const DHCP_SEARCH_INFO* SearchInfo,
    DHCP_CLIENT_INFO_EX** ClientInfo
);
[DllImport("DHCPSAPI.dll", ExactSpelling = true)]
static extern uint DhcpV4GetClientInfoEx(
    [MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress,   // LPCWSTR optional
    IntPtr SearchInfo,   // DHCP_SEARCH_INFO*
    IntPtr ClientInfo   // DHCP_CLIENT_INFO_EX** out
);
<DllImport("DHCPSAPI.dll", ExactSpelling:=True)>
Public Shared Function DhcpV4GetClientInfoEx(
    <MarshalAs(UnmanagedType.LPWStr)> ServerIpAddress As String,   ' LPCWSTR optional
    SearchInfo As IntPtr,   ' DHCP_SEARCH_INFO*
    ClientInfo As IntPtr   ' DHCP_CLIENT_INFO_EX** out
) As UInteger
End Function
' ServerIpAddress : LPCWSTR optional
' SearchInfo : DHCP_SEARCH_INFO*
' ClientInfo : DHCP_CLIENT_INFO_EX** out
Declare PtrSafe Function DhcpV4GetClientInfoEx Lib "dhcpsapi" ( _
    ByVal ServerIpAddress As LongPtr, _
    ByVal SearchInfo As LongPtr, _
    ByVal ClientInfo As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DhcpV4GetClientInfoEx = ctypes.windll.dhcpsapi.DhcpV4GetClientInfoEx
DhcpV4GetClientInfoEx.restype = wintypes.DWORD
DhcpV4GetClientInfoEx.argtypes = [
    wintypes.LPCWSTR,  # ServerIpAddress : LPCWSTR optional
    ctypes.c_void_p,  # SearchInfo : DHCP_SEARCH_INFO*
    ctypes.c_void_p,  # ClientInfo : DHCP_CLIENT_INFO_EX** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('DHCPSAPI.dll')
DhcpV4GetClientInfoEx = Fiddle::Function.new(
  lib['DhcpV4GetClientInfoEx'],
  [
    Fiddle::TYPE_VOIDP,  # ServerIpAddress : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # SearchInfo : DHCP_SEARCH_INFO*
    Fiddle::TYPE_VOIDP,  # ClientInfo : DHCP_CLIENT_INFO_EX** out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "dhcpsapi")]
extern "system" {
    fn DhcpV4GetClientInfoEx(
        ServerIpAddress: *const u16,  // LPCWSTR optional
        SearchInfo: *const DHCP_SEARCH_INFO,  // DHCP_SEARCH_INFO*
        ClientInfo: *mut *mut DHCP_CLIENT_INFO_EX  // DHCP_CLIENT_INFO_EX** out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("DHCPSAPI.dll")]
public static extern uint DhcpV4GetClientInfoEx([MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress, IntPtr SearchInfo, IntPtr ClientInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DHCPSAPI_DhcpV4GetClientInfoEx' -Namespace Win32 -PassThru
# $api::DhcpV4GetClientInfoEx(ServerIpAddress, SearchInfo, ClientInfo)
#uselib "DHCPSAPI.dll"
#func global DhcpV4GetClientInfoEx "DhcpV4GetClientInfoEx" sptr, sptr, sptr
; DhcpV4GetClientInfoEx ServerIpAddress, varptr(SearchInfo), varptr(ClientInfo)   ; 戻り値は stat
; ServerIpAddress : LPCWSTR optional -> "sptr"
; SearchInfo : DHCP_SEARCH_INFO* -> "sptr"
; ClientInfo : DHCP_CLIENT_INFO_EX** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "DHCPSAPI.dll"
#cfunc global DhcpV4GetClientInfoEx "DhcpV4GetClientInfoEx" wstr, var, var
; res = DhcpV4GetClientInfoEx(ServerIpAddress, SearchInfo, ClientInfo)
; ServerIpAddress : LPCWSTR optional -> "wstr"
; SearchInfo : DHCP_SEARCH_INFO* -> "var"
; ClientInfo : DHCP_CLIENT_INFO_EX** out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD DhcpV4GetClientInfoEx(LPCWSTR ServerIpAddress, DHCP_SEARCH_INFO* SearchInfo, DHCP_CLIENT_INFO_EX** ClientInfo)
#uselib "DHCPSAPI.dll"
#cfunc global DhcpV4GetClientInfoEx "DhcpV4GetClientInfoEx" wstr, var, var
; res = DhcpV4GetClientInfoEx(ServerIpAddress, SearchInfo, ClientInfo)
; ServerIpAddress : LPCWSTR optional -> "wstr"
; SearchInfo : DHCP_SEARCH_INFO* -> "var"
; ClientInfo : DHCP_CLIENT_INFO_EX** out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	dhcpsapi = windows.NewLazySystemDLL("DHCPSAPI.dll")
	procDhcpV4GetClientInfoEx = dhcpsapi.NewProc("DhcpV4GetClientInfoEx")
)

// ServerIpAddress (LPCWSTR optional), SearchInfo (DHCP_SEARCH_INFO*), ClientInfo (DHCP_CLIENT_INFO_EX** out)
r1, _, err := procDhcpV4GetClientInfoEx.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ServerIpAddress))),
	uintptr(SearchInfo),
	uintptr(ClientInfo),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function DhcpV4GetClientInfoEx(
  ServerIpAddress: PWideChar;   // LPCWSTR optional
  SearchInfo: Pointer;   // DHCP_SEARCH_INFO*
  ClientInfo: Pointer   // DHCP_CLIENT_INFO_EX** out
): DWORD; stdcall;
  external 'DHCPSAPI.dll' name 'DhcpV4GetClientInfoEx';
result := DllCall("DHCPSAPI\DhcpV4GetClientInfoEx"
    , "WStr", ServerIpAddress   ; LPCWSTR optional
    , "Ptr", SearchInfo   ; DHCP_SEARCH_INFO*
    , "Ptr", ClientInfo   ; DHCP_CLIENT_INFO_EX** out
    , "UInt")   ; return: DWORD
●DhcpV4GetClientInfoEx(ServerIpAddress, SearchInfo, ClientInfo) = DLL("DHCPSAPI.dll", "dword DhcpV4GetClientInfoEx(char*, void*, void*)")
# 呼び出し: DhcpV4GetClientInfoEx(ServerIpAddress, SearchInfo, ClientInfo)
# ServerIpAddress : LPCWSTR optional -> "char*"
# SearchInfo : DHCP_SEARCH_INFO* -> "void*"
# ClientInfo : DHCP_CLIENT_INFO_EX** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。