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