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

DhcpGetAllOptionValuesV6

関数
指定IPv6スコープに設定された全DHCPオプション値を取得する。
DLLDHCPSAPI.dll呼出規約winapi対応OSwindowsserver2008

シグネチャ

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

DWORD DhcpGetAllOptionValuesV6(
    LPWSTR ServerIpAddress,   // optional
    DWORD Flags,
    DHCP_OPTION_SCOPE_INFO6* ScopeInfo,
    DHCP_ALL_OPTION_VALUES** Values
);

パラメーター

名前方向
ServerIpAddressLPWSTRinoptional
FlagsDWORDin
ScopeInfoDHCP_OPTION_SCOPE_INFO6*inout
ValuesDHCP_ALL_OPTION_VALUES**inout

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD DhcpGetAllOptionValuesV6(
    LPWSTR ServerIpAddress,   // optional
    DWORD Flags,
    DHCP_OPTION_SCOPE_INFO6* ScopeInfo,
    DHCP_ALL_OPTION_VALUES** Values
);
[DllImport("DHCPSAPI.dll", ExactSpelling = true)]
static extern uint DhcpGetAllOptionValuesV6(
    [MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress,   // LPWSTR optional
    uint Flags,   // DWORD
    IntPtr ScopeInfo,   // DHCP_OPTION_SCOPE_INFO6* in/out
    IntPtr Values   // DHCP_ALL_OPTION_VALUES** in/out
);
<DllImport("DHCPSAPI.dll", ExactSpelling:=True)>
Public Shared Function DhcpGetAllOptionValuesV6(
    <MarshalAs(UnmanagedType.LPWStr)> ServerIpAddress As String,   ' LPWSTR optional
    Flags As UInteger,   ' DWORD
    ScopeInfo As IntPtr,   ' DHCP_OPTION_SCOPE_INFO6* in/out
    Values As IntPtr   ' DHCP_ALL_OPTION_VALUES** in/out
) As UInteger
End Function
' ServerIpAddress : LPWSTR optional
' Flags : DWORD
' ScopeInfo : DHCP_OPTION_SCOPE_INFO6* in/out
' Values : DHCP_ALL_OPTION_VALUES** in/out
Declare PtrSafe Function DhcpGetAllOptionValuesV6 Lib "dhcpsapi" ( _
    ByVal ServerIpAddress As LongPtr, _
    ByVal Flags As Long, _
    ByVal ScopeInfo As LongPtr, _
    ByVal Values As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DhcpGetAllOptionValuesV6 = ctypes.windll.dhcpsapi.DhcpGetAllOptionValuesV6
DhcpGetAllOptionValuesV6.restype = wintypes.DWORD
DhcpGetAllOptionValuesV6.argtypes = [
    wintypes.LPCWSTR,  # ServerIpAddress : LPWSTR optional
    wintypes.DWORD,  # Flags : DWORD
    ctypes.c_void_p,  # ScopeInfo : DHCP_OPTION_SCOPE_INFO6* in/out
    ctypes.c_void_p,  # Values : DHCP_ALL_OPTION_VALUES** in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('DHCPSAPI.dll')
DhcpGetAllOptionValuesV6 = Fiddle::Function.new(
  lib['DhcpGetAllOptionValuesV6'],
  [
    Fiddle::TYPE_VOIDP,  # ServerIpAddress : LPWSTR optional
    -Fiddle::TYPE_INT,  # Flags : DWORD
    Fiddle::TYPE_VOIDP,  # ScopeInfo : DHCP_OPTION_SCOPE_INFO6* in/out
    Fiddle::TYPE_VOIDP,  # Values : DHCP_ALL_OPTION_VALUES** in/out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "dhcpsapi")]
extern "system" {
    fn DhcpGetAllOptionValuesV6(
        ServerIpAddress: *mut u16,  // LPWSTR optional
        Flags: u32,  // DWORD
        ScopeInfo: *mut DHCP_OPTION_SCOPE_INFO6,  // DHCP_OPTION_SCOPE_INFO6* in/out
        Values: *mut *mut DHCP_ALL_OPTION_VALUES  // DHCP_ALL_OPTION_VALUES** in/out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("DHCPSAPI.dll")]
public static extern uint DhcpGetAllOptionValuesV6([MarshalAs(UnmanagedType.LPWStr)] string ServerIpAddress, uint Flags, IntPtr ScopeInfo, IntPtr Values);
"@
$api = Add-Type -MemberDefinition $sig -Name 'DHCPSAPI_DhcpGetAllOptionValuesV6' -Namespace Win32 -PassThru
# $api::DhcpGetAllOptionValuesV6(ServerIpAddress, Flags, ScopeInfo, Values)
#uselib "DHCPSAPI.dll"
#func global DhcpGetAllOptionValuesV6 "DhcpGetAllOptionValuesV6" sptr, sptr, sptr, sptr
; DhcpGetAllOptionValuesV6 ServerIpAddress, Flags, varptr(ScopeInfo), varptr(Values)   ; 戻り値は stat
; ServerIpAddress : LPWSTR optional -> "sptr"
; Flags : DWORD -> "sptr"
; ScopeInfo : DHCP_OPTION_SCOPE_INFO6* in/out -> "sptr"
; Values : DHCP_ALL_OPTION_VALUES** in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "DHCPSAPI.dll"
#cfunc global DhcpGetAllOptionValuesV6 "DhcpGetAllOptionValuesV6" wstr, int, var, var
; res = DhcpGetAllOptionValuesV6(ServerIpAddress, Flags, ScopeInfo, Values)
; ServerIpAddress : LPWSTR optional -> "wstr"
; Flags : DWORD -> "int"
; ScopeInfo : DHCP_OPTION_SCOPE_INFO6* in/out -> "var"
; Values : DHCP_ALL_OPTION_VALUES** in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD DhcpGetAllOptionValuesV6(LPWSTR ServerIpAddress, DWORD Flags, DHCP_OPTION_SCOPE_INFO6* ScopeInfo, DHCP_ALL_OPTION_VALUES** Values)
#uselib "DHCPSAPI.dll"
#cfunc global DhcpGetAllOptionValuesV6 "DhcpGetAllOptionValuesV6" wstr, int, var, var
; res = DhcpGetAllOptionValuesV6(ServerIpAddress, Flags, ScopeInfo, Values)
; ServerIpAddress : LPWSTR optional -> "wstr"
; Flags : DWORD -> "int"
; ScopeInfo : DHCP_OPTION_SCOPE_INFO6* in/out -> "var"
; Values : DHCP_ALL_OPTION_VALUES** in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	dhcpsapi = windows.NewLazySystemDLL("DHCPSAPI.dll")
	procDhcpGetAllOptionValuesV6 = dhcpsapi.NewProc("DhcpGetAllOptionValuesV6")
)

// ServerIpAddress (LPWSTR optional), Flags (DWORD), ScopeInfo (DHCP_OPTION_SCOPE_INFO6* in/out), Values (DHCP_ALL_OPTION_VALUES** in/out)
r1, _, err := procDhcpGetAllOptionValuesV6.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ServerIpAddress))),
	uintptr(Flags),
	uintptr(ScopeInfo),
	uintptr(Values),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function DhcpGetAllOptionValuesV6(
  ServerIpAddress: PWideChar;   // LPWSTR optional
  Flags: DWORD;   // DWORD
  ScopeInfo: Pointer;   // DHCP_OPTION_SCOPE_INFO6* in/out
  Values: Pointer   // DHCP_ALL_OPTION_VALUES** in/out
): DWORD; stdcall;
  external 'DHCPSAPI.dll' name 'DhcpGetAllOptionValuesV6';
result := DllCall("DHCPSAPI\DhcpGetAllOptionValuesV6"
    , "WStr", ServerIpAddress   ; LPWSTR optional
    , "UInt", Flags   ; DWORD
    , "Ptr", ScopeInfo   ; DHCP_OPTION_SCOPE_INFO6* in/out
    , "Ptr", Values   ; DHCP_ALL_OPTION_VALUES** in/out
    , "UInt")   ; return: DWORD
●DhcpGetAllOptionValuesV6(ServerIpAddress, Flags, ScopeInfo, Values) = DLL("DHCPSAPI.dll", "dword DhcpGetAllOptionValuesV6(char*, dword, void*, void*)")
# 呼び出し: DhcpGetAllOptionValuesV6(ServerIpAddress, Flags, ScopeInfo, Values)
# ServerIpAddress : LPWSTR optional -> "char*"
# Flags : DWORD -> "dword"
# ScopeInfo : DHCP_OPTION_SCOPE_INFO6* in/out -> "void*"
# Values : DHCP_ALL_OPTION_VALUES** in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。