ホーム › NetworkManagement.Dhcp › DhcpSetClientInfoV6
DhcpSetClientInfoV6
関数DHCPサーバー上のIPv6クライアントの予約情報を設定する。
シグネチャ
// DHCPSAPI.dll
#include <windows.h>
DWORD DhcpSetClientInfoV6(
LPCWSTR ServerIpAddress, // optional
const DHCP_CLIENT_INFO_V6* ClientInfo
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ServerIpAddress | LPCWSTR | inoptional | 対象DHCPv6サーバーのIPアドレスを示すUnicode文字列。ローカルならNULL可。 |
| ClientInfo | DHCP_CLIENT_INFO_V6* | in | 設定するIPv6クライアントのリース情報を保持するDHCP_CLIENT_INFO_V6構造体へのポインタ。 |
戻り値の型: DWORD
各言語での呼び出し定義
// DHCPSAPI.dll
#include <windows.h>
DWORD DhcpSetClientInfoV6(
LPCWSTR ServerIpAddress, // optional
const DHCP_CLIENT_INFO_V6* ClientInfo
);[DllImport("DHCPSAPI.dll", ExactSpelling = true)]
static extern uint DhcpSetClientInfoV6(
[MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress, // LPCWSTR optional
IntPtr ClientInfo // DHCP_CLIENT_INFO_V6*
);<DllImport("DHCPSAPI.dll", ExactSpelling:=True)>
Public Shared Function DhcpSetClientInfoV6(
<MarshalAs(UnmanagedType.LPWStr)> ServerIpAddress As String, ' LPCWSTR optional
ClientInfo As IntPtr ' DHCP_CLIENT_INFO_V6*
) As UInteger
End Function' ServerIpAddress : LPCWSTR optional
' ClientInfo : DHCP_CLIENT_INFO_V6*
Declare PtrSafe Function DhcpSetClientInfoV6 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
DhcpSetClientInfoV6 = ctypes.windll.dhcpsapi.DhcpSetClientInfoV6
DhcpSetClientInfoV6.restype = wintypes.DWORD
DhcpSetClientInfoV6.argtypes = [
wintypes.LPCWSTR, # ServerIpAddress : LPCWSTR optional
ctypes.c_void_p, # ClientInfo : DHCP_CLIENT_INFO_V6*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('DHCPSAPI.dll')
DhcpSetClientInfoV6 = Fiddle::Function.new(
lib['DhcpSetClientInfoV6'],
[
Fiddle::TYPE_VOIDP, # ServerIpAddress : LPCWSTR optional
Fiddle::TYPE_VOIDP, # ClientInfo : DHCP_CLIENT_INFO_V6*
],
-Fiddle::TYPE_INT)#[link(name = "dhcpsapi")]
extern "system" {
fn DhcpSetClientInfoV6(
ServerIpAddress: *const u16, // LPCWSTR optional
ClientInfo: *const DHCP_CLIENT_INFO_V6 // DHCP_CLIENT_INFO_V6*
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("DHCPSAPI.dll")]
public static extern uint DhcpSetClientInfoV6([MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress, IntPtr ClientInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DHCPSAPI_DhcpSetClientInfoV6' -Namespace Win32 -PassThru
# $api::DhcpSetClientInfoV6(ServerIpAddress, ClientInfo)#uselib "DHCPSAPI.dll"
#func global DhcpSetClientInfoV6 "DhcpSetClientInfoV6" sptr, sptr
; DhcpSetClientInfoV6 ServerIpAddress, varptr(ClientInfo) ; 戻り値は stat
; ServerIpAddress : LPCWSTR optional -> "sptr"
; ClientInfo : DHCP_CLIENT_INFO_V6* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "DHCPSAPI.dll" #cfunc global DhcpSetClientInfoV6 "DhcpSetClientInfoV6" wstr, var ; res = DhcpSetClientInfoV6(ServerIpAddress, ClientInfo) ; ServerIpAddress : LPCWSTR optional -> "wstr" ; ClientInfo : DHCP_CLIENT_INFO_V6* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "DHCPSAPI.dll" #cfunc global DhcpSetClientInfoV6 "DhcpSetClientInfoV6" wstr, sptr ; res = DhcpSetClientInfoV6(ServerIpAddress, varptr(ClientInfo)) ; ServerIpAddress : LPCWSTR optional -> "wstr" ; ClientInfo : DHCP_CLIENT_INFO_V6* -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD DhcpSetClientInfoV6(LPCWSTR ServerIpAddress, DHCP_CLIENT_INFO_V6* ClientInfo) #uselib "DHCPSAPI.dll" #cfunc global DhcpSetClientInfoV6 "DhcpSetClientInfoV6" wstr, var ; res = DhcpSetClientInfoV6(ServerIpAddress, ClientInfo) ; ServerIpAddress : LPCWSTR optional -> "wstr" ; ClientInfo : DHCP_CLIENT_INFO_V6* -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD DhcpSetClientInfoV6(LPCWSTR ServerIpAddress, DHCP_CLIENT_INFO_V6* ClientInfo) #uselib "DHCPSAPI.dll" #cfunc global DhcpSetClientInfoV6 "DhcpSetClientInfoV6" wstr, intptr ; res = DhcpSetClientInfoV6(ServerIpAddress, varptr(ClientInfo)) ; ServerIpAddress : LPCWSTR optional -> "wstr" ; ClientInfo : DHCP_CLIENT_INFO_V6* -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
dhcpsapi = windows.NewLazySystemDLL("DHCPSAPI.dll")
procDhcpSetClientInfoV6 = dhcpsapi.NewProc("DhcpSetClientInfoV6")
)
// ServerIpAddress (LPCWSTR optional), ClientInfo (DHCP_CLIENT_INFO_V6*)
r1, _, err := procDhcpSetClientInfoV6.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ServerIpAddress))),
uintptr(ClientInfo),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction DhcpSetClientInfoV6(
ServerIpAddress: PWideChar; // LPCWSTR optional
ClientInfo: Pointer // DHCP_CLIENT_INFO_V6*
): DWORD; stdcall;
external 'DHCPSAPI.dll' name 'DhcpSetClientInfoV6';result := DllCall("DHCPSAPI\DhcpSetClientInfoV6"
, "WStr", ServerIpAddress ; LPCWSTR optional
, "Ptr", ClientInfo ; DHCP_CLIENT_INFO_V6*
, "UInt") ; return: DWORD●DhcpSetClientInfoV6(ServerIpAddress, ClientInfo) = DLL("DHCPSAPI.dll", "dword DhcpSetClientInfoV6(char*, void*)")
# 呼び出し: DhcpSetClientInfoV6(ServerIpAddress, ClientInfo)
# ServerIpAddress : LPCWSTR optional -> "char*"
# ClientInfo : DHCP_CLIENT_INFO_V6* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "dhcpsapi" fn DhcpSetClientInfoV6(
ServerIpAddress: [*c]const u16, // LPCWSTR optional
ClientInfo: [*c]DHCP_CLIENT_INFO_V6 // DHCP_CLIENT_INFO_V6*
) callconv(std.os.windows.WINAPI) u32;proc DhcpSetClientInfoV6(
ServerIpAddress: WideCString, # LPCWSTR optional
ClientInfo: ptr DHCP_CLIENT_INFO_V6 # DHCP_CLIENT_INFO_V6*
): uint32 {.importc: "DhcpSetClientInfoV6", stdcall, dynlib: "DHCPSAPI.dll".}pragma(lib, "dhcpsapi");
extern(Windows)
uint DhcpSetClientInfoV6(
const(wchar)* ServerIpAddress, // LPCWSTR optional
DHCP_CLIENT_INFO_V6* ClientInfo // DHCP_CLIENT_INFO_V6*
);ccall((:DhcpSetClientInfoV6, "DHCPSAPI.dll"), stdcall, UInt32,
(Cwstring, Ptr{DHCP_CLIENT_INFO_V6}),
ServerIpAddress, ClientInfo)
# ServerIpAddress : LPCWSTR optional -> Cwstring
# ClientInfo : DHCP_CLIENT_INFO_V6* -> Ptr{DHCP_CLIENT_INFO_V6}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t DhcpSetClientInfoV6(
const uint16_t* ServerIpAddress,
void* ClientInfo);
]]
local dhcpsapi = ffi.load("dhcpsapi")
-- dhcpsapi.DhcpSetClientInfoV6(ServerIpAddress, ClientInfo)
-- ServerIpAddress : LPCWSTR optional
-- ClientInfo : DHCP_CLIENT_INFO_V6*
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('DHCPSAPI.dll');
const DhcpSetClientInfoV6 = lib.func('__stdcall', 'DhcpSetClientInfoV6', 'uint32_t', ['str16', 'void *']);
// DhcpSetClientInfoV6(ServerIpAddress, ClientInfo)
// ServerIpAddress : LPCWSTR optional -> 'str16'
// ClientInfo : DHCP_CLIENT_INFO_V6* -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("DHCPSAPI.dll", {
DhcpSetClientInfoV6: { parameters: ["buffer", "pointer"], result: "u32" },
});
// lib.symbols.DhcpSetClientInfoV6(ServerIpAddress, ClientInfo)
// ServerIpAddress : LPCWSTR optional -> "buffer"
// ClientInfo : DHCP_CLIENT_INFO_V6* -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t DhcpSetClientInfoV6(
const uint16_t* ServerIpAddress,
void* ClientInfo);
C, "DHCPSAPI.dll");
// $ffi->DhcpSetClientInfoV6(ServerIpAddress, ClientInfo);
// ServerIpAddress : LPCWSTR optional
// ClientInfo : DHCP_CLIENT_INFO_V6*
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Dhcpsapi extends StdCallLibrary {
Dhcpsapi INSTANCE = Native.load("dhcpsapi", Dhcpsapi.class);
int DhcpSetClientInfoV6(
WString ServerIpAddress, // LPCWSTR optional
Pointer ClientInfo // DHCP_CLIENT_INFO_V6*
);
}@[Link("dhcpsapi")]
lib LibDHCPSAPI
fun DhcpSetClientInfoV6 = DhcpSetClientInfoV6(
ServerIpAddress : UInt16*, # LPCWSTR optional
ClientInfo : DHCP_CLIENT_INFO_V6* # DHCP_CLIENT_INFO_V6*
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DhcpSetClientInfoV6Native = Uint32 Function(Pointer<Utf16>, Pointer<Void>);
typedef DhcpSetClientInfoV6Dart = int Function(Pointer<Utf16>, Pointer<Void>);
final DhcpSetClientInfoV6 = DynamicLibrary.open('DHCPSAPI.dll')
.lookupFunction<DhcpSetClientInfoV6Native, DhcpSetClientInfoV6Dart>('DhcpSetClientInfoV6');
// ServerIpAddress : LPCWSTR optional -> Pointer<Utf16>
// ClientInfo : DHCP_CLIENT_INFO_V6* -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function DhcpSetClientInfoV6(
ServerIpAddress: PWideChar; // LPCWSTR optional
ClientInfo: Pointer // DHCP_CLIENT_INFO_V6*
): DWORD; stdcall;
external 'DHCPSAPI.dll' name 'DhcpSetClientInfoV6';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DhcpSetClientInfoV6"
c_DhcpSetClientInfoV6 :: CWString -> Ptr () -> IO Word32
-- ServerIpAddress : LPCWSTR optional -> CWString
-- ClientInfo : DHCP_CLIENT_INFO_V6* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let dhcpsetclientinfov6 =
foreign "DhcpSetClientInfoV6"
((ptr uint16_t) @-> (ptr void) @-> returning uint32_t)
(* ServerIpAddress : LPCWSTR optional -> (ptr uint16_t) *)
(* ClientInfo : DHCP_CLIENT_INFO_V6* -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library dhcpsapi (t "DHCPSAPI.dll"))
(cffi:use-foreign-library dhcpsapi)
(cffi:defcfun ("DhcpSetClientInfoV6" dhcp-set-client-info-v6 :convention :stdcall) :uint32
(server-ip-address (:string :encoding :utf-16le)) ; LPCWSTR optional
(client-info :pointer)) ; DHCP_CLIENT_INFO_V6*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DhcpSetClientInfoV6 = Win32::API::More->new('DHCPSAPI',
'DWORD DhcpSetClientInfoV6(LPCWSTR ServerIpAddress, LPVOID ClientInfo)');
# my $ret = $DhcpSetClientInfoV6->Call($ServerIpAddress, $ClientInfo);
# ServerIpAddress : LPCWSTR optional -> LPCWSTR
# ClientInfo : DHCP_CLIENT_INFO_V6* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
類似 API
- f DhcpSetClientInfoV4 — DHCPサーバーのV4拡張クライアント予約情報を設定する。