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

DhcpGetAllOptionsV6

関数
DHCPサーバーのIPv6向け全オプション定義を取得する。
DLLDHCPSAPI.dll呼出規約winapi対応OSwindowsserver2008

シグネチャ

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

DWORD DhcpGetAllOptionsV6(
    LPWSTR ServerIpAddress,   // optional
    DWORD Flags,
    DHCP_ALL_OPTIONS** OptionStruct
);

パラメーター

名前方向
ServerIpAddressLPWSTRinoptional
FlagsDWORDin
OptionStructDHCP_ALL_OPTIONS**inout

戻り値の型: DWORD

各言語での呼び出し定義

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

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

DhcpGetAllOptionsV6 = ctypes.windll.dhcpsapi.DhcpGetAllOptionsV6
DhcpGetAllOptionsV6.restype = wintypes.DWORD
DhcpGetAllOptionsV6.argtypes = [
    wintypes.LPCWSTR,  # ServerIpAddress : LPWSTR optional
    wintypes.DWORD,  # Flags : DWORD
    ctypes.c_void_p,  # OptionStruct : DHCP_ALL_OPTIONS** in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	dhcpsapi = windows.NewLazySystemDLL("DHCPSAPI.dll")
	procDhcpGetAllOptionsV6 = dhcpsapi.NewProc("DhcpGetAllOptionsV6")
)

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