Win32 API 日本語リファレンス
ホームSystem.DeploymentServices › PxeDhcpv6AppendOption

PxeDhcpv6AppendOption

関数
DHCPv6応答パケットにオプションを追加する。
DLLWDSPXE.dll呼出規約winapi対応OSwindows8.0

シグネチャ

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

DWORD PxeDhcpv6AppendOption(
    void* pReply,
    DWORD cbReply,
    DWORD* pcbReplyUsed,
    WORD wOptionType,
    WORD cbOption,
    void* pOption
);

パラメーター

名前方向説明
pReplyvoid*inoutオプションを追記する対象のDHCPv6応答パケットバッファ。
cbReplyDWORDin応答バッファの最大サイズ(バイト単位)。
pcbReplyUsedDWORD*inout現在の応答長を入力し追記後の長さを受け取るDWORDポインタ。
wOptionTypeWORDin追加するDHCPv6オプションのタイプ番号。
cbOptionWORDinオプション値の長さ(バイト単位)。
pOptionvoid*in追加するオプション値データへのポインタ。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD PxeDhcpv6AppendOption(
    void* pReply,
    DWORD cbReply,
    DWORD* pcbReplyUsed,
    WORD wOptionType,
    WORD cbOption,
    void* pOption
);
[DllImport("WDSPXE.dll", ExactSpelling = true)]
static extern uint PxeDhcpv6AppendOption(
    IntPtr pReply,   // void* in/out
    uint cbReply,   // DWORD
    ref uint pcbReplyUsed,   // DWORD* in/out
    ushort wOptionType,   // WORD
    ushort cbOption,   // WORD
    IntPtr pOption   // void*
);
<DllImport("WDSPXE.dll", ExactSpelling:=True)>
Public Shared Function PxeDhcpv6AppendOption(
    pReply As IntPtr,   ' void* in/out
    cbReply As UInteger,   ' DWORD
    ByRef pcbReplyUsed As UInteger,   ' DWORD* in/out
    wOptionType As UShort,   ' WORD
    cbOption As UShort,   ' WORD
    pOption As IntPtr   ' void*
) As UInteger
End Function
' pReply : void* in/out
' cbReply : DWORD
' pcbReplyUsed : DWORD* in/out
' wOptionType : WORD
' cbOption : WORD
' pOption : void*
Declare PtrSafe Function PxeDhcpv6AppendOption Lib "wdspxe" ( _
    ByVal pReply As LongPtr, _
    ByVal cbReply As Long, _
    ByRef pcbReplyUsed As Long, _
    ByVal wOptionType As Integer, _
    ByVal cbOption As Integer, _
    ByVal pOption As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PxeDhcpv6AppendOption = ctypes.windll.wdspxe.PxeDhcpv6AppendOption
PxeDhcpv6AppendOption.restype = wintypes.DWORD
PxeDhcpv6AppendOption.argtypes = [
    ctypes.POINTER(None),  # pReply : void* in/out
    wintypes.DWORD,  # cbReply : DWORD
    ctypes.POINTER(wintypes.DWORD),  # pcbReplyUsed : DWORD* in/out
    ctypes.c_ushort,  # wOptionType : WORD
    ctypes.c_ushort,  # cbOption : WORD
    ctypes.POINTER(None),  # pOption : void*
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WDSPXE.dll')
PxeDhcpv6AppendOption = Fiddle::Function.new(
  lib['PxeDhcpv6AppendOption'],
  [
    Fiddle::TYPE_VOIDP,  # pReply : void* in/out
    -Fiddle::TYPE_INT,  # cbReply : DWORD
    Fiddle::TYPE_VOIDP,  # pcbReplyUsed : DWORD* in/out
    -Fiddle::TYPE_SHORT,  # wOptionType : WORD
    -Fiddle::TYPE_SHORT,  # cbOption : WORD
    Fiddle::TYPE_VOIDP,  # pOption : void*
  ],
  -Fiddle::TYPE_INT)
#[link(name = "wdspxe")]
extern "system" {
    fn PxeDhcpv6AppendOption(
        pReply: *mut (),  // void* in/out
        cbReply: u32,  // DWORD
        pcbReplyUsed: *mut u32,  // DWORD* in/out
        wOptionType: u16,  // WORD
        cbOption: u16,  // WORD
        pOption: *mut ()  // void*
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("WDSPXE.dll")]
public static extern uint PxeDhcpv6AppendOption(IntPtr pReply, uint cbReply, ref uint pcbReplyUsed, ushort wOptionType, ushort cbOption, IntPtr pOption);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WDSPXE_PxeDhcpv6AppendOption' -Namespace Win32 -PassThru
# $api::PxeDhcpv6AppendOption(pReply, cbReply, pcbReplyUsed, wOptionType, cbOption, pOption)
#uselib "WDSPXE.dll"
#func global PxeDhcpv6AppendOption "PxeDhcpv6AppendOption" sptr, sptr, sptr, sptr, sptr, sptr
; PxeDhcpv6AppendOption pReply, cbReply, varptr(pcbReplyUsed), wOptionType, cbOption, pOption   ; 戻り値は stat
; pReply : void* in/out -> "sptr"
; cbReply : DWORD -> "sptr"
; pcbReplyUsed : DWORD* in/out -> "sptr"
; wOptionType : WORD -> "sptr"
; cbOption : WORD -> "sptr"
; pOption : void* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WDSPXE.dll"
#cfunc global PxeDhcpv6AppendOption "PxeDhcpv6AppendOption" sptr, int, var, int, int, sptr
; res = PxeDhcpv6AppendOption(pReply, cbReply, pcbReplyUsed, wOptionType, cbOption, pOption)
; pReply : void* in/out -> "sptr"
; cbReply : DWORD -> "int"
; pcbReplyUsed : DWORD* in/out -> "var"
; wOptionType : WORD -> "int"
; cbOption : WORD -> "int"
; pOption : void* -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD PxeDhcpv6AppendOption(void* pReply, DWORD cbReply, DWORD* pcbReplyUsed, WORD wOptionType, WORD cbOption, void* pOption)
#uselib "WDSPXE.dll"
#cfunc global PxeDhcpv6AppendOption "PxeDhcpv6AppendOption" intptr, int, var, int, int, intptr
; res = PxeDhcpv6AppendOption(pReply, cbReply, pcbReplyUsed, wOptionType, cbOption, pOption)
; pReply : void* in/out -> "intptr"
; cbReply : DWORD -> "int"
; pcbReplyUsed : DWORD* in/out -> "var"
; wOptionType : WORD -> "int"
; cbOption : WORD -> "int"
; pOption : void* -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wdspxe = windows.NewLazySystemDLL("WDSPXE.dll")
	procPxeDhcpv6AppendOption = wdspxe.NewProc("PxeDhcpv6AppendOption")
)

// pReply (void* in/out), cbReply (DWORD), pcbReplyUsed (DWORD* in/out), wOptionType (WORD), cbOption (WORD), pOption (void*)
r1, _, err := procPxeDhcpv6AppendOption.Call(
	uintptr(pReply),
	uintptr(cbReply),
	uintptr(pcbReplyUsed),
	uintptr(wOptionType),
	uintptr(cbOption),
	uintptr(pOption),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function PxeDhcpv6AppendOption(
  pReply: Pointer;   // void* in/out
  cbReply: DWORD;   // DWORD
  pcbReplyUsed: Pointer;   // DWORD* in/out
  wOptionType: Word;   // WORD
  cbOption: Word;   // WORD
  pOption: Pointer   // void*
): DWORD; stdcall;
  external 'WDSPXE.dll' name 'PxeDhcpv6AppendOption';
result := DllCall("WDSPXE\PxeDhcpv6AppendOption"
    , "Ptr", pReply   ; void* in/out
    , "UInt", cbReply   ; DWORD
    , "Ptr", pcbReplyUsed   ; DWORD* in/out
    , "UShort", wOptionType   ; WORD
    , "UShort", cbOption   ; WORD
    , "Ptr", pOption   ; void*
    , "UInt")   ; return: DWORD
●PxeDhcpv6AppendOption(pReply, cbReply, pcbReplyUsed, wOptionType, cbOption, pOption) = DLL("WDSPXE.dll", "dword PxeDhcpv6AppendOption(void*, dword, void*, int, int, void*)")
# 呼び出し: PxeDhcpv6AppendOption(pReply, cbReply, pcbReplyUsed, wOptionType, cbOption, pOption)
# pReply : void* in/out -> "void*"
# cbReply : DWORD -> "dword"
# pcbReplyUsed : DWORD* in/out -> "void*"
# wOptionType : WORD -> "int"
# cbOption : WORD -> "int"
# pOption : void* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "wdspxe" fn PxeDhcpv6AppendOption(
    pReply: ?*anyopaque, // void* in/out
    cbReply: u32, // DWORD
    pcbReplyUsed: [*c]u32, // DWORD* in/out
    wOptionType: u16, // WORD
    cbOption: u16, // WORD
    pOption: ?*anyopaque // void*
) callconv(std.os.windows.WINAPI) u32;
proc PxeDhcpv6AppendOption(
    pReply: pointer,  # void* in/out
    cbReply: uint32,  # DWORD
    pcbReplyUsed: ptr uint32,  # DWORD* in/out
    wOptionType: uint16,  # WORD
    cbOption: uint16,  # WORD
    pOption: pointer  # void*
): uint32 {.importc: "PxeDhcpv6AppendOption", stdcall, dynlib: "WDSPXE.dll".}
pragma(lib, "wdspxe");
extern(Windows)
uint PxeDhcpv6AppendOption(
    void* pReply,   // void* in/out
    uint cbReply,   // DWORD
    uint* pcbReplyUsed,   // DWORD* in/out
    ushort wOptionType,   // WORD
    ushort cbOption,   // WORD
    void* pOption   // void*
);
ccall((:PxeDhcpv6AppendOption, "WDSPXE.dll"), stdcall, UInt32,
      (Ptr{Cvoid}, UInt32, Ptr{UInt32}, UInt16, UInt16, Ptr{Cvoid}),
      pReply, cbReply, pcbReplyUsed, wOptionType, cbOption, pOption)
# pReply : void* in/out -> Ptr{Cvoid}
# cbReply : DWORD -> UInt32
# pcbReplyUsed : DWORD* in/out -> Ptr{UInt32}
# wOptionType : WORD -> UInt16
# cbOption : WORD -> UInt16
# pOption : void* -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t PxeDhcpv6AppendOption(
    void* pReply,
    uint32_t cbReply,
    uint32_t* pcbReplyUsed,
    uint16_t wOptionType,
    uint16_t cbOption,
    void* pOption);
]]
local wdspxe = ffi.load("wdspxe")
-- wdspxe.PxeDhcpv6AppendOption(pReply, cbReply, pcbReplyUsed, wOptionType, cbOption, pOption)
-- pReply : void* in/out
-- cbReply : DWORD
-- pcbReplyUsed : DWORD* in/out
-- wOptionType : WORD
-- cbOption : WORD
-- pOption : void*
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('WDSPXE.dll');
const PxeDhcpv6AppendOption = lib.func('__stdcall', 'PxeDhcpv6AppendOption', 'uint32_t', ['void *', 'uint32_t', 'uint32_t *', 'uint16_t', 'uint16_t', 'void *']);
// PxeDhcpv6AppendOption(pReply, cbReply, pcbReplyUsed, wOptionType, cbOption, pOption)
// pReply : void* in/out -> 'void *'
// cbReply : DWORD -> 'uint32_t'
// pcbReplyUsed : DWORD* in/out -> 'uint32_t *'
// wOptionType : WORD -> 'uint16_t'
// cbOption : WORD -> 'uint16_t'
// pOption : void* -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("WDSPXE.dll", {
  PxeDhcpv6AppendOption: { parameters: ["pointer", "u32", "pointer", "u16", "u16", "pointer"], result: "u32" },
});
// lib.symbols.PxeDhcpv6AppendOption(pReply, cbReply, pcbReplyUsed, wOptionType, cbOption, pOption)
// pReply : void* in/out -> "pointer"
// cbReply : DWORD -> "u32"
// pcbReplyUsed : DWORD* in/out -> "pointer"
// wOptionType : WORD -> "u16"
// cbOption : WORD -> "u16"
// pOption : void* -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t PxeDhcpv6AppendOption(
    void* pReply,
    uint32_t cbReply,
    uint32_t* pcbReplyUsed,
    uint16_t wOptionType,
    uint16_t cbOption,
    void* pOption);
C, "WDSPXE.dll");
// $ffi->PxeDhcpv6AppendOption(pReply, cbReply, pcbReplyUsed, wOptionType, cbOption, pOption);
// pReply : void* in/out
// cbReply : DWORD
// pcbReplyUsed : DWORD* in/out
// wOptionType : WORD
// cbOption : WORD
// pOption : void*
// 構造体/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 Wdspxe extends StdCallLibrary {
    Wdspxe INSTANCE = Native.load("wdspxe", Wdspxe.class);
    int PxeDhcpv6AppendOption(
        Pointer pReply,   // void* in/out
        int cbReply,   // DWORD
        IntByReference pcbReplyUsed,   // DWORD* in/out
        short wOptionType,   // WORD
        short cbOption,   // WORD
        Pointer pOption   // void*
    );
}
@[Link("wdspxe")]
lib LibWDSPXE
  fun PxeDhcpv6AppendOption = PxeDhcpv6AppendOption(
    pReply : Void*,   # void* in/out
    cbReply : UInt32,   # DWORD
    pcbReplyUsed : UInt32*,   # DWORD* in/out
    wOptionType : UInt16,   # WORD
    cbOption : UInt16,   # WORD
    pOption : Void*   # void*
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef PxeDhcpv6AppendOptionNative = Uint32 Function(Pointer<Void>, Uint32, Pointer<Uint32>, Uint16, Uint16, Pointer<Void>);
typedef PxeDhcpv6AppendOptionDart = int Function(Pointer<Void>, int, Pointer<Uint32>, int, int, Pointer<Void>);
final PxeDhcpv6AppendOption = DynamicLibrary.open('WDSPXE.dll')
    .lookupFunction<PxeDhcpv6AppendOptionNative, PxeDhcpv6AppendOptionDart>('PxeDhcpv6AppendOption');
// pReply : void* in/out -> Pointer<Void>
// cbReply : DWORD -> Uint32
// pcbReplyUsed : DWORD* in/out -> Pointer<Uint32>
// wOptionType : WORD -> Uint16
// cbOption : WORD -> Uint16
// pOption : void* -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function PxeDhcpv6AppendOption(
  pReply: Pointer;   // void* in/out
  cbReply: DWORD;   // DWORD
  pcbReplyUsed: Pointer;   // DWORD* in/out
  wOptionType: Word;   // WORD
  cbOption: Word;   // WORD
  pOption: Pointer   // void*
): DWORD; stdcall;
  external 'WDSPXE.dll' name 'PxeDhcpv6AppendOption';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "PxeDhcpv6AppendOption"
  c_PxeDhcpv6AppendOption :: Ptr () -> Word32 -> Ptr Word32 -> Word16 -> Word16 -> Ptr () -> IO Word32
-- pReply : void* in/out -> Ptr ()
-- cbReply : DWORD -> Word32
-- pcbReplyUsed : DWORD* in/out -> Ptr Word32
-- wOptionType : WORD -> Word16
-- cbOption : WORD -> Word16
-- pOption : void* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let pxedhcpv6appendoption =
  foreign "PxeDhcpv6AppendOption"
    ((ptr void) @-> uint32_t @-> (ptr uint32_t) @-> uint16_t @-> uint16_t @-> (ptr void) @-> returning uint32_t)
(* pReply : void* in/out -> (ptr void) *)
(* cbReply : DWORD -> uint32_t *)
(* pcbReplyUsed : DWORD* in/out -> (ptr uint32_t) *)
(* wOptionType : WORD -> uint16_t *)
(* cbOption : WORD -> uint16_t *)
(* pOption : void* -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library wdspxe (t "WDSPXE.dll"))
(cffi:use-foreign-library wdspxe)

(cffi:defcfun ("PxeDhcpv6AppendOption" pxe-dhcpv6-append-option :convention :stdcall) :uint32
  (p-reply :pointer)   ; void* in/out
  (cb-reply :uint32)   ; DWORD
  (pcb-reply-used :pointer)   ; DWORD* in/out
  (w-option-type :uint16)   ; WORD
  (cb-option :uint16)   ; WORD
  (p-option :pointer))   ; void*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $PxeDhcpv6AppendOption = Win32::API::More->new('WDSPXE',
    'DWORD PxeDhcpv6AppendOption(LPVOID pReply, DWORD cbReply, LPVOID pcbReplyUsed, WORD wOptionType, WORD cbOption, LPVOID pOption)');
# my $ret = $PxeDhcpv6AppendOption->Call($pReply, $cbReply, $pcbReplyUsed, $wOptionType, $cbOption, $pOption);
# pReply : void* in/out -> LPVOID
# cbReply : DWORD -> DWORD
# pcbReplyUsed : DWORD* in/out -> LPVOID
# wOptionType : WORD -> WORD
# cbOption : WORD -> WORD
# pOption : void* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。