ホーム › NetworkManagement.Dhcp › DhcpCreateClientInfo
DhcpCreateClientInfo
関数DHCPサーバーにクライアント予約情報を作成する。
シグネチャ
// DHCPSAPI.dll
#include <windows.h>
DWORD DhcpCreateClientInfo(
LPCWSTR ServerIpAddress, // optional
const DHCP_CLIENT_INFO* ClientInfo
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| ServerIpAddress | LPCWSTR | inoptional |
| ClientInfo | DHCP_CLIENT_INFO* | in |
戻り値の型: DWORD
各言語での呼び出し定義
// DHCPSAPI.dll
#include <windows.h>
DWORD DhcpCreateClientInfo(
LPCWSTR ServerIpAddress, // optional
const DHCP_CLIENT_INFO* ClientInfo
);[DllImport("DHCPSAPI.dll", ExactSpelling = true)]
static extern uint DhcpCreateClientInfo(
[MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress, // LPCWSTR optional
IntPtr ClientInfo // DHCP_CLIENT_INFO*
);<DllImport("DHCPSAPI.dll", ExactSpelling:=True)>
Public Shared Function DhcpCreateClientInfo(
<MarshalAs(UnmanagedType.LPWStr)> ServerIpAddress As String, ' LPCWSTR optional
ClientInfo As IntPtr ' DHCP_CLIENT_INFO*
) As UInteger
End Function' ServerIpAddress : LPCWSTR optional
' ClientInfo : DHCP_CLIENT_INFO*
Declare PtrSafe Function DhcpCreateClientInfo 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
DhcpCreateClientInfo = ctypes.windll.dhcpsapi.DhcpCreateClientInfo
DhcpCreateClientInfo.restype = wintypes.DWORD
DhcpCreateClientInfo.argtypes = [
wintypes.LPCWSTR, # ServerIpAddress : LPCWSTR optional
ctypes.c_void_p, # ClientInfo : DHCP_CLIENT_INFO*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('DHCPSAPI.dll')
DhcpCreateClientInfo = Fiddle::Function.new(
lib['DhcpCreateClientInfo'],
[
Fiddle::TYPE_VOIDP, # ServerIpAddress : LPCWSTR optional
Fiddle::TYPE_VOIDP, # ClientInfo : DHCP_CLIENT_INFO*
],
-Fiddle::TYPE_INT)#[link(name = "dhcpsapi")]
extern "system" {
fn DhcpCreateClientInfo(
ServerIpAddress: *const u16, // LPCWSTR optional
ClientInfo: *const DHCP_CLIENT_INFO // DHCP_CLIENT_INFO*
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("DHCPSAPI.dll")]
public static extern uint DhcpCreateClientInfo([MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress, IntPtr ClientInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DHCPSAPI_DhcpCreateClientInfo' -Namespace Win32 -PassThru
# $api::DhcpCreateClientInfo(ServerIpAddress, ClientInfo)#uselib "DHCPSAPI.dll"
#func global DhcpCreateClientInfo "DhcpCreateClientInfo" sptr, sptr
; DhcpCreateClientInfo ServerIpAddress, varptr(ClientInfo) ; 戻り値は stat
; ServerIpAddress : LPCWSTR optional -> "sptr"
; ClientInfo : DHCP_CLIENT_INFO* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "DHCPSAPI.dll" #cfunc global DhcpCreateClientInfo "DhcpCreateClientInfo" wstr, var ; res = DhcpCreateClientInfo(ServerIpAddress, ClientInfo) ; ServerIpAddress : LPCWSTR optional -> "wstr" ; ClientInfo : DHCP_CLIENT_INFO* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "DHCPSAPI.dll" #cfunc global DhcpCreateClientInfo "DhcpCreateClientInfo" wstr, sptr ; res = DhcpCreateClientInfo(ServerIpAddress, varptr(ClientInfo)) ; ServerIpAddress : LPCWSTR optional -> "wstr" ; ClientInfo : DHCP_CLIENT_INFO* -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD DhcpCreateClientInfo(LPCWSTR ServerIpAddress, DHCP_CLIENT_INFO* ClientInfo) #uselib "DHCPSAPI.dll" #cfunc global DhcpCreateClientInfo "DhcpCreateClientInfo" wstr, var ; res = DhcpCreateClientInfo(ServerIpAddress, ClientInfo) ; ServerIpAddress : LPCWSTR optional -> "wstr" ; ClientInfo : DHCP_CLIENT_INFO* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD DhcpCreateClientInfo(LPCWSTR ServerIpAddress, DHCP_CLIENT_INFO* ClientInfo) #uselib "DHCPSAPI.dll" #cfunc global DhcpCreateClientInfo "DhcpCreateClientInfo" wstr, intptr ; res = DhcpCreateClientInfo(ServerIpAddress, varptr(ClientInfo)) ; ServerIpAddress : LPCWSTR optional -> "wstr" ; ClientInfo : DHCP_CLIENT_INFO* -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
dhcpsapi = windows.NewLazySystemDLL("DHCPSAPI.dll")
procDhcpCreateClientInfo = dhcpsapi.NewProc("DhcpCreateClientInfo")
)
// ServerIpAddress (LPCWSTR optional), ClientInfo (DHCP_CLIENT_INFO*)
r1, _, err := procDhcpCreateClientInfo.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ServerIpAddress))),
uintptr(ClientInfo),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction DhcpCreateClientInfo(
ServerIpAddress: PWideChar; // LPCWSTR optional
ClientInfo: Pointer // DHCP_CLIENT_INFO*
): DWORD; stdcall;
external 'DHCPSAPI.dll' name 'DhcpCreateClientInfo';result := DllCall("DHCPSAPI\DhcpCreateClientInfo"
, "WStr", ServerIpAddress ; LPCWSTR optional
, "Ptr", ClientInfo ; DHCP_CLIENT_INFO*
, "UInt") ; return: DWORD●DhcpCreateClientInfo(ServerIpAddress, ClientInfo) = DLL("DHCPSAPI.dll", "dword DhcpCreateClientInfo(char*, void*)")
# 呼び出し: DhcpCreateClientInfo(ServerIpAddress, ClientInfo)
# ServerIpAddress : LPCWSTR optional -> "char*"
# ClientInfo : DHCP_CLIENT_INFO* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。