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

DhcpServerSetConfigV6

関数
DHCPサーバーのIPv6向け構成パラメータを設定する。
DLLDHCPSAPI.dll呼出規約winapi対応OSwindowsserver2008

シグネチャ

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

DWORD DhcpServerSetConfigV6(
    LPCWSTR ServerIpAddress,   // optional
    DHCP_OPTION_SCOPE_INFO6* ScopeInfo,
    DWORD FieldsToSet,
    DHCP_SERVER_CONFIG_INFO_V6* ConfigInfo
);

パラメーター

名前方向
ServerIpAddressLPCWSTRinoptional
ScopeInfoDHCP_OPTION_SCOPE_INFO6*inout
FieldsToSetDWORDin
ConfigInfoDHCP_SERVER_CONFIG_INFO_V6*inout

戻り値の型: 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 方式にも切替可。
出力引数:
; 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 方式にも切替可。
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   // DWORD
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';
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)。