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