ホーム › NetworkManagement.Dhcp › DhcpServerGetConfigV6
DhcpServerGetConfigV6
関数DHCPサーバーのIPv6向け構成パラメータを取得する。
シグネチャ
// DHCPSAPI.dll
#include <windows.h>
DWORD DhcpServerGetConfigV6(
LPCWSTR ServerIpAddress, // optional
DHCP_OPTION_SCOPE_INFO6* ScopeInfo,
DHCP_SERVER_CONFIG_INFO_V6** ConfigInfo
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| ServerIpAddress | LPCWSTR | inoptional |
| ScopeInfo | DHCP_OPTION_SCOPE_INFO6* | inout |
| ConfigInfo | DHCP_SERVER_CONFIG_INFO_V6** | inout |
戻り値の型: DWORD
各言語での呼び出し定義
// DHCPSAPI.dll
#include <windows.h>
DWORD DhcpServerGetConfigV6(
LPCWSTR ServerIpAddress, // optional
DHCP_OPTION_SCOPE_INFO6* ScopeInfo,
DHCP_SERVER_CONFIG_INFO_V6** ConfigInfo
);[DllImport("DHCPSAPI.dll", ExactSpelling = true)]
static extern uint DhcpServerGetConfigV6(
[MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress, // LPCWSTR optional
IntPtr ScopeInfo, // DHCP_OPTION_SCOPE_INFO6* in/out
IntPtr ConfigInfo // DHCP_SERVER_CONFIG_INFO_V6** in/out
);<DllImport("DHCPSAPI.dll", ExactSpelling:=True)>
Public Shared Function DhcpServerGetConfigV6(
<MarshalAs(UnmanagedType.LPWStr)> ServerIpAddress As String, ' LPCWSTR optional
ScopeInfo As IntPtr, ' DHCP_OPTION_SCOPE_INFO6* in/out
ConfigInfo As IntPtr ' DHCP_SERVER_CONFIG_INFO_V6** in/out
) As UInteger
End Function' ServerIpAddress : LPCWSTR optional
' ScopeInfo : DHCP_OPTION_SCOPE_INFO6* in/out
' ConfigInfo : DHCP_SERVER_CONFIG_INFO_V6** in/out
Declare PtrSafe Function DhcpServerGetConfigV6 Lib "dhcpsapi" ( _
ByVal ServerIpAddress As LongPtr, _
ByVal ScopeInfo As LongPtr, _
ByVal ConfigInfo As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DhcpServerGetConfigV6 = ctypes.windll.dhcpsapi.DhcpServerGetConfigV6
DhcpServerGetConfigV6.restype = wintypes.DWORD
DhcpServerGetConfigV6.argtypes = [
wintypes.LPCWSTR, # ServerIpAddress : LPCWSTR optional
ctypes.c_void_p, # ScopeInfo : DHCP_OPTION_SCOPE_INFO6* in/out
ctypes.c_void_p, # ConfigInfo : DHCP_SERVER_CONFIG_INFO_V6** in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('DHCPSAPI.dll')
DhcpServerGetConfigV6 = Fiddle::Function.new(
lib['DhcpServerGetConfigV6'],
[
Fiddle::TYPE_VOIDP, # ServerIpAddress : LPCWSTR optional
Fiddle::TYPE_VOIDP, # ScopeInfo : DHCP_OPTION_SCOPE_INFO6* in/out
Fiddle::TYPE_VOIDP, # ConfigInfo : DHCP_SERVER_CONFIG_INFO_V6** in/out
],
-Fiddle::TYPE_INT)#[link(name = "dhcpsapi")]
extern "system" {
fn DhcpServerGetConfigV6(
ServerIpAddress: *const u16, // LPCWSTR optional
ScopeInfo: *mut DHCP_OPTION_SCOPE_INFO6, // DHCP_OPTION_SCOPE_INFO6* in/out
ConfigInfo: *mut *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 DhcpServerGetConfigV6([MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress, IntPtr ScopeInfo, IntPtr ConfigInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DHCPSAPI_DhcpServerGetConfigV6' -Namespace Win32 -PassThru
# $api::DhcpServerGetConfigV6(ServerIpAddress, ScopeInfo, ConfigInfo)#uselib "DHCPSAPI.dll"
#func global DhcpServerGetConfigV6 "DhcpServerGetConfigV6" sptr, sptr, sptr
; DhcpServerGetConfigV6 ServerIpAddress, varptr(ScopeInfo), varptr(ConfigInfo) ; 戻り値は stat
; ServerIpAddress : LPCWSTR optional -> "sptr"
; ScopeInfo : DHCP_OPTION_SCOPE_INFO6* in/out -> "sptr"
; ConfigInfo : DHCP_SERVER_CONFIG_INFO_V6** in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "DHCPSAPI.dll" #cfunc global DhcpServerGetConfigV6 "DhcpServerGetConfigV6" wstr, var, var ; res = DhcpServerGetConfigV6(ServerIpAddress, ScopeInfo, ConfigInfo) ; ServerIpAddress : LPCWSTR optional -> "wstr" ; ScopeInfo : DHCP_OPTION_SCOPE_INFO6* in/out -> "var" ; ConfigInfo : DHCP_SERVER_CONFIG_INFO_V6** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "DHCPSAPI.dll" #cfunc global DhcpServerGetConfigV6 "DhcpServerGetConfigV6" wstr, sptr, sptr ; res = DhcpServerGetConfigV6(ServerIpAddress, varptr(ScopeInfo), varptr(ConfigInfo)) ; ServerIpAddress : LPCWSTR optional -> "wstr" ; ScopeInfo : DHCP_OPTION_SCOPE_INFO6* in/out -> "sptr" ; ConfigInfo : DHCP_SERVER_CONFIG_INFO_V6** in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD DhcpServerGetConfigV6(LPCWSTR ServerIpAddress, DHCP_OPTION_SCOPE_INFO6* ScopeInfo, DHCP_SERVER_CONFIG_INFO_V6** ConfigInfo) #uselib "DHCPSAPI.dll" #cfunc global DhcpServerGetConfigV6 "DhcpServerGetConfigV6" wstr, var, var ; res = DhcpServerGetConfigV6(ServerIpAddress, ScopeInfo, ConfigInfo) ; ServerIpAddress : LPCWSTR optional -> "wstr" ; ScopeInfo : DHCP_OPTION_SCOPE_INFO6* in/out -> "var" ; ConfigInfo : DHCP_SERVER_CONFIG_INFO_V6** in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD DhcpServerGetConfigV6(LPCWSTR ServerIpAddress, DHCP_OPTION_SCOPE_INFO6* ScopeInfo, DHCP_SERVER_CONFIG_INFO_V6** ConfigInfo) #uselib "DHCPSAPI.dll" #cfunc global DhcpServerGetConfigV6 "DhcpServerGetConfigV6" wstr, intptr, intptr ; res = DhcpServerGetConfigV6(ServerIpAddress, varptr(ScopeInfo), varptr(ConfigInfo)) ; ServerIpAddress : LPCWSTR optional -> "wstr" ; ScopeInfo : DHCP_OPTION_SCOPE_INFO6* in/out -> "intptr" ; 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")
procDhcpServerGetConfigV6 = dhcpsapi.NewProc("DhcpServerGetConfigV6")
)
// ServerIpAddress (LPCWSTR optional), ScopeInfo (DHCP_OPTION_SCOPE_INFO6* in/out), ConfigInfo (DHCP_SERVER_CONFIG_INFO_V6** in/out)
r1, _, err := procDhcpServerGetConfigV6.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ServerIpAddress))),
uintptr(ScopeInfo),
uintptr(ConfigInfo),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction DhcpServerGetConfigV6(
ServerIpAddress: PWideChar; // LPCWSTR optional
ScopeInfo: Pointer; // DHCP_OPTION_SCOPE_INFO6* in/out
ConfigInfo: Pointer // DHCP_SERVER_CONFIG_INFO_V6** in/out
): DWORD; stdcall;
external 'DHCPSAPI.dll' name 'DhcpServerGetConfigV6';result := DllCall("DHCPSAPI\DhcpServerGetConfigV6"
, "WStr", ServerIpAddress ; LPCWSTR optional
, "Ptr", ScopeInfo ; DHCP_OPTION_SCOPE_INFO6* in/out
, "Ptr", ConfigInfo ; DHCP_SERVER_CONFIG_INFO_V6** in/out
, "UInt") ; return: DWORD●DhcpServerGetConfigV6(ServerIpAddress, ScopeInfo, ConfigInfo) = DLL("DHCPSAPI.dll", "dword DhcpServerGetConfigV6(char*, void*, void*)")
# 呼び出し: DhcpServerGetConfigV6(ServerIpAddress, ScopeInfo, ConfigInfo)
# ServerIpAddress : LPCWSTR optional -> "char*"
# ScopeInfo : DHCP_OPTION_SCOPE_INFO6* in/out -> "void*"
# ConfigInfo : DHCP_SERVER_CONFIG_INFO_V6** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。