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

DhcpV4CreateClientInfo

関数
DHCPサーバーに新しいIPv4クライアント予約情報を作成する。
DLLDHCPSAPI.dll呼出規約winapi対応OSwindowsserver2012

シグネチャ

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

DWORD DhcpV4CreateClientInfo(
    LPCWSTR ServerIpAddress,   // optional
    const DHCP_CLIENT_INFO_PB* ClientInfo
);

パラメーター

名前方向
ServerIpAddressLPCWSTRinoptional
ClientInfoDHCP_CLIENT_INFO_PB*in

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD DhcpV4CreateClientInfo(
    LPCWSTR ServerIpAddress,   // optional
    const DHCP_CLIENT_INFO_PB* ClientInfo
);
[DllImport("DHCPSAPI.dll", ExactSpelling = true)]
static extern uint DhcpV4CreateClientInfo(
    [MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress,   // LPCWSTR optional
    IntPtr ClientInfo   // DHCP_CLIENT_INFO_PB*
);
<DllImport("DHCPSAPI.dll", ExactSpelling:=True)>
Public Shared Function DhcpV4CreateClientInfo(
    <MarshalAs(UnmanagedType.LPWStr)> ServerIpAddress As String,   ' LPCWSTR optional
    ClientInfo As IntPtr   ' DHCP_CLIENT_INFO_PB*
) As UInteger
End Function
' ServerIpAddress : LPCWSTR optional
' ClientInfo : DHCP_CLIENT_INFO_PB*
Declare PtrSafe Function DhcpV4CreateClientInfo Lib "dhcpsapi" ( _
    ByVal ServerIpAddress 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

DhcpV4CreateClientInfo = ctypes.windll.dhcpsapi.DhcpV4CreateClientInfo
DhcpV4CreateClientInfo.restype = wintypes.DWORD
DhcpV4CreateClientInfo.argtypes = [
    wintypes.LPCWSTR,  # ServerIpAddress : LPCWSTR optional
    ctypes.c_void_p,  # ClientInfo : DHCP_CLIENT_INFO_PB*
]
require 'fiddle'
require 'fiddle/import'

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

var (
	dhcpsapi = windows.NewLazySystemDLL("DHCPSAPI.dll")
	procDhcpV4CreateClientInfo = dhcpsapi.NewProc("DhcpV4CreateClientInfo")
)

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