ホーム › NetworkManagement.Dhcp › DhcpGetAllOptionValuesV6
DhcpGetAllOptionValuesV6
関数指定IPv6スコープに設定された全DHCPオプション値を取得する。
シグネチャ
// DHCPSAPI.dll
#include <windows.h>
DWORD DhcpGetAllOptionValuesV6(
LPWSTR ServerIpAddress, // optional
DWORD Flags,
DHCP_OPTION_SCOPE_INFO6* ScopeInfo,
DHCP_ALL_OPTION_VALUES** Values
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ServerIpAddress | LPWSTR | inoptional | 操作対象DHCPサーバのIPアドレスまたはホスト名(Unicode)。 |
| Flags | DWORD | in | 予約フラグ。通常は0を指定する。 |
| ScopeInfo | DHCP_OPTION_SCOPE_INFO6* | inout | 取得対象のIPv6範囲を示すDHCP_OPTION_SCOPE_INFO6構造体へのポインタ。 |
| Values | DHCP_ALL_OPTION_VALUES** | inout | 取得した全DHCPv6オプション値を受け取るDHCP_ALL_OPTION_VALUESへのポインタ。RPC割当てで要解放。 |
戻り値の型: 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 方式にも切替可。#uselib "DHCPSAPI.dll" #cfunc global DhcpGetAllOptionValuesV6 "DhcpGetAllOptionValuesV6" wstr, int, sptr, sptr ; res = DhcpGetAllOptionValuesV6(ServerIpAddress, Flags, varptr(ScopeInfo), varptr(Values)) ; ServerIpAddress : LPWSTR optional -> "wstr" ; Flags : DWORD -> "int" ; ScopeInfo : DHCP_OPTION_SCOPE_INFO6* in/out -> "sptr" ; Values : DHCP_ALL_OPTION_VALUES** in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; 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, intptr, intptr ; res = DhcpGetAllOptionValuesV6(ServerIpAddress, Flags, varptr(ScopeInfo), varptr(Values)) ; ServerIpAddress : LPWSTR optional -> "wstr" ; Flags : DWORD -> "int" ; ScopeInfo : DHCP_OPTION_SCOPE_INFO6* in/out -> "intptr" ; Values : DHCP_ALL_OPTION_VALUES** in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // DWORDfunction 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)。const std = @import("std");
extern "dhcpsapi" fn DhcpGetAllOptionValuesV6(
ServerIpAddress: [*c]const u16, // LPWSTR optional
Flags: u32, // DWORD
ScopeInfo: [*c]DHCP_OPTION_SCOPE_INFO6, // DHCP_OPTION_SCOPE_INFO6* in/out
Values: [*c][*c]DHCP_ALL_OPTION_VALUES // DHCP_ALL_OPTION_VALUES** in/out
) callconv(std.os.windows.WINAPI) u32;proc DhcpGetAllOptionValuesV6(
ServerIpAddress: WideCString, # LPWSTR optional
Flags: uint32, # DWORD
ScopeInfo: ptr DHCP_OPTION_SCOPE_INFO6, # DHCP_OPTION_SCOPE_INFO6* in/out
Values: ptr DHCP_ALL_OPTION_VALUES # DHCP_ALL_OPTION_VALUES** in/out
): uint32 {.importc: "DhcpGetAllOptionValuesV6", stdcall, dynlib: "DHCPSAPI.dll".}pragma(lib, "dhcpsapi");
extern(Windows)
uint DhcpGetAllOptionValuesV6(
const(wchar)* ServerIpAddress, // LPWSTR optional
uint Flags, // DWORD
DHCP_OPTION_SCOPE_INFO6* ScopeInfo, // DHCP_OPTION_SCOPE_INFO6* in/out
DHCP_ALL_OPTION_VALUES** Values // DHCP_ALL_OPTION_VALUES** in/out
);ccall((:DhcpGetAllOptionValuesV6, "DHCPSAPI.dll"), stdcall, UInt32,
(Cwstring, UInt32, Ptr{DHCP_OPTION_SCOPE_INFO6}, Ptr{DHCP_ALL_OPTION_VALUES}),
ServerIpAddress, Flags, ScopeInfo, Values)
# ServerIpAddress : LPWSTR optional -> Cwstring
# Flags : DWORD -> UInt32
# ScopeInfo : DHCP_OPTION_SCOPE_INFO6* in/out -> Ptr{DHCP_OPTION_SCOPE_INFO6}
# Values : DHCP_ALL_OPTION_VALUES** in/out -> Ptr{DHCP_ALL_OPTION_VALUES}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t DhcpGetAllOptionValuesV6(
const uint16_t* ServerIpAddress,
uint32_t Flags,
void* ScopeInfo,
void* Values);
]]
local dhcpsapi = ffi.load("dhcpsapi")
-- dhcpsapi.DhcpGetAllOptionValuesV6(ServerIpAddress, Flags, ScopeInfo, Values)
-- ServerIpAddress : LPWSTR optional
-- Flags : DWORD
-- ScopeInfo : DHCP_OPTION_SCOPE_INFO6* in/out
-- Values : DHCP_ALL_OPTION_VALUES** in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('DHCPSAPI.dll');
const DhcpGetAllOptionValuesV6 = lib.func('__stdcall', 'DhcpGetAllOptionValuesV6', 'uint32_t', ['str16', 'uint32_t', 'void *', 'void *']);
// DhcpGetAllOptionValuesV6(ServerIpAddress, Flags, ScopeInfo, Values)
// ServerIpAddress : LPWSTR optional -> 'str16'
// Flags : DWORD -> 'uint32_t'
// ScopeInfo : DHCP_OPTION_SCOPE_INFO6* in/out -> 'void *'
// Values : DHCP_ALL_OPTION_VALUES** in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("DHCPSAPI.dll", {
DhcpGetAllOptionValuesV6: { parameters: ["buffer", "u32", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.DhcpGetAllOptionValuesV6(ServerIpAddress, Flags, ScopeInfo, Values)
// ServerIpAddress : LPWSTR optional -> "buffer"
// Flags : DWORD -> "u32"
// ScopeInfo : DHCP_OPTION_SCOPE_INFO6* in/out -> "pointer"
// Values : DHCP_ALL_OPTION_VALUES** in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t DhcpGetAllOptionValuesV6(
const uint16_t* ServerIpAddress,
uint32_t Flags,
void* ScopeInfo,
void* Values);
C, "DHCPSAPI.dll");
// $ffi->DhcpGetAllOptionValuesV6(ServerIpAddress, Flags, ScopeInfo, Values);
// ServerIpAddress : LPWSTR optional
// Flags : DWORD
// ScopeInfo : DHCP_OPTION_SCOPE_INFO6* in/out
// Values : DHCP_ALL_OPTION_VALUES** 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 DhcpGetAllOptionValuesV6(
WString ServerIpAddress, // LPWSTR optional
int Flags, // DWORD
Pointer ScopeInfo, // DHCP_OPTION_SCOPE_INFO6* in/out
Pointer Values // DHCP_ALL_OPTION_VALUES** in/out
);
}@[Link("dhcpsapi")]
lib LibDHCPSAPI
fun DhcpGetAllOptionValuesV6 = DhcpGetAllOptionValuesV6(
ServerIpAddress : UInt16*, # LPWSTR optional
Flags : UInt32, # DWORD
ScopeInfo : DHCP_OPTION_SCOPE_INFO6*, # DHCP_OPTION_SCOPE_INFO6* in/out
Values : DHCP_ALL_OPTION_VALUES** # DHCP_ALL_OPTION_VALUES** 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 DhcpGetAllOptionValuesV6Native = Uint32 Function(Pointer<Utf16>, Uint32, Pointer<Void>, Pointer<Void>);
typedef DhcpGetAllOptionValuesV6Dart = int Function(Pointer<Utf16>, int, Pointer<Void>, Pointer<Void>);
final DhcpGetAllOptionValuesV6 = DynamicLibrary.open('DHCPSAPI.dll')
.lookupFunction<DhcpGetAllOptionValuesV6Native, DhcpGetAllOptionValuesV6Dart>('DhcpGetAllOptionValuesV6');
// ServerIpAddress : LPWSTR optional -> Pointer<Utf16>
// Flags : DWORD -> Uint32
// ScopeInfo : DHCP_OPTION_SCOPE_INFO6* in/out -> Pointer<Void>
// Values : DHCP_ALL_OPTION_VALUES** in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DhcpGetAllOptionValuesV6"
c_DhcpGetAllOptionValuesV6 :: CWString -> Word32 -> Ptr () -> Ptr () -> IO Word32
-- ServerIpAddress : LPWSTR optional -> CWString
-- Flags : DWORD -> Word32
-- ScopeInfo : DHCP_OPTION_SCOPE_INFO6* in/out -> Ptr ()
-- Values : DHCP_ALL_OPTION_VALUES** in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let dhcpgetalloptionvaluesv6 =
foreign "DhcpGetAllOptionValuesV6"
((ptr uint16_t) @-> uint32_t @-> (ptr void) @-> (ptr void) @-> returning uint32_t)
(* ServerIpAddress : LPWSTR optional -> (ptr uint16_t) *)
(* Flags : DWORD -> uint32_t *)
(* ScopeInfo : DHCP_OPTION_SCOPE_INFO6* in/out -> (ptr void) *)
(* Values : DHCP_ALL_OPTION_VALUES** 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 ("DhcpGetAllOptionValuesV6" dhcp-get-all-option-values-v6 :convention :stdcall) :uint32
(server-ip-address (:string :encoding :utf-16le)) ; LPWSTR optional
(flags :uint32) ; DWORD
(scope-info :pointer) ; DHCP_OPTION_SCOPE_INFO6* in/out
(values :pointer)) ; DHCP_ALL_OPTION_VALUES** in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DhcpGetAllOptionValuesV6 = Win32::API::More->new('DHCPSAPI',
'DWORD DhcpGetAllOptionValuesV6(LPCWSTR ServerIpAddress, DWORD Flags, LPVOID ScopeInfo, LPVOID Values)');
# my $ret = $DhcpGetAllOptionValuesV6->Call($ServerIpAddress, $Flags, $ScopeInfo, $Values);
# ServerIpAddress : LPWSTR optional -> LPCWSTR
# Flags : DWORD -> DWORD
# ScopeInfo : DHCP_OPTION_SCOPE_INFO6* in/out -> LPVOID
# Values : DHCP_ALL_OPTION_VALUES** in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。