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

PxeDhcpAppendOption

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

シグネチャ

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

DWORD PxeDhcpAppendOption(
    void* pReplyPacket,
    DWORD uMaxReplyPacketLen,
    DWORD* puReplyPacketLen,
    BYTE bOption,
    BYTE bOptionLen,
    void* pValue   // optional
);

パラメーター

名前方向説明
pReplyPacketvoid*inoutオプションを追記する対象のDHCP応答パケットバッファ。
uMaxReplyPacketLenDWORDin応答バッファの最大サイズ(バイト単位)。
puReplyPacketLenDWORD*inout現在の応答長を入力し追記後の長さを受け取るDWORDポインタ。
bOptionBYTEin追加するDHCPオプションのコード。
bOptionLenBYTEinオプション値の長さ(バイト単位)。
pValuevoid*inoptional追加するオプション値データへのポインタ。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD PxeDhcpAppendOption(
    void* pReplyPacket,
    DWORD uMaxReplyPacketLen,
    DWORD* puReplyPacketLen,
    BYTE bOption,
    BYTE bOptionLen,
    void* pValue   // optional
);
[DllImport("WDSPXE.dll", ExactSpelling = true)]
static extern uint PxeDhcpAppendOption(
    IntPtr pReplyPacket,   // void* in/out
    uint uMaxReplyPacketLen,   // DWORD
    ref uint puReplyPacketLen,   // DWORD* in/out
    byte bOption,   // BYTE
    byte bOptionLen,   // BYTE
    IntPtr pValue   // void* optional
);
<DllImport("WDSPXE.dll", ExactSpelling:=True)>
Public Shared Function PxeDhcpAppendOption(
    pReplyPacket As IntPtr,   ' void* in/out
    uMaxReplyPacketLen As UInteger,   ' DWORD
    ByRef puReplyPacketLen As UInteger,   ' DWORD* in/out
    bOption As Byte,   ' BYTE
    bOptionLen As Byte,   ' BYTE
    pValue As IntPtr   ' void* optional
) As UInteger
End Function
' pReplyPacket : void* in/out
' uMaxReplyPacketLen : DWORD
' puReplyPacketLen : DWORD* in/out
' bOption : BYTE
' bOptionLen : BYTE
' pValue : void* optional
Declare PtrSafe Function PxeDhcpAppendOption Lib "wdspxe" ( _
    ByVal pReplyPacket As LongPtr, _
    ByVal uMaxReplyPacketLen As Long, _
    ByRef puReplyPacketLen As Long, _
    ByVal bOption As Byte, _
    ByVal bOptionLen As Byte, _
    ByVal pValue As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PxeDhcpAppendOption = ctypes.windll.wdspxe.PxeDhcpAppendOption
PxeDhcpAppendOption.restype = wintypes.DWORD
PxeDhcpAppendOption.argtypes = [
    ctypes.POINTER(None),  # pReplyPacket : void* in/out
    wintypes.DWORD,  # uMaxReplyPacketLen : DWORD
    ctypes.POINTER(wintypes.DWORD),  # puReplyPacketLen : DWORD* in/out
    ctypes.c_ubyte,  # bOption : BYTE
    ctypes.c_ubyte,  # bOptionLen : BYTE
    ctypes.POINTER(None),  # pValue : void* optional
]
require 'fiddle'
require 'fiddle/import'

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

var (
	wdspxe = windows.NewLazySystemDLL("WDSPXE.dll")
	procPxeDhcpAppendOption = wdspxe.NewProc("PxeDhcpAppendOption")
)

// pReplyPacket (void* in/out), uMaxReplyPacketLen (DWORD), puReplyPacketLen (DWORD* in/out), bOption (BYTE), bOptionLen (BYTE), pValue (void* optional)
r1, _, err := procPxeDhcpAppendOption.Call(
	uintptr(pReplyPacket),
	uintptr(uMaxReplyPacketLen),
	uintptr(puReplyPacketLen),
	uintptr(bOption),
	uintptr(bOptionLen),
	uintptr(pValue),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function PxeDhcpAppendOption(
  pReplyPacket: Pointer;   // void* in/out
  uMaxReplyPacketLen: DWORD;   // DWORD
  puReplyPacketLen: Pointer;   // DWORD* in/out
  bOption: Byte;   // BYTE
  bOptionLen: Byte;   // BYTE
  pValue: Pointer   // void* optional
): DWORD; stdcall;
  external 'WDSPXE.dll' name 'PxeDhcpAppendOption';
result := DllCall("WDSPXE\PxeDhcpAppendOption"
    , "Ptr", pReplyPacket   ; void* in/out
    , "UInt", uMaxReplyPacketLen   ; DWORD
    , "Ptr", puReplyPacketLen   ; DWORD* in/out
    , "UChar", bOption   ; BYTE
    , "UChar", bOptionLen   ; BYTE
    , "Ptr", pValue   ; void* optional
    , "UInt")   ; return: DWORD
●PxeDhcpAppendOption(pReplyPacket, uMaxReplyPacketLen, puReplyPacketLen, bOption, bOptionLen, pValue) = DLL("WDSPXE.dll", "dword PxeDhcpAppendOption(void*, dword, void*, byte, byte, void*)")
# 呼び出し: PxeDhcpAppendOption(pReplyPacket, uMaxReplyPacketLen, puReplyPacketLen, bOption, bOptionLen, pValue)
# pReplyPacket : void* in/out -> "void*"
# uMaxReplyPacketLen : DWORD -> "dword"
# puReplyPacketLen : DWORD* in/out -> "void*"
# bOption : BYTE -> "byte"
# bOptionLen : BYTE -> "byte"
# pValue : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef PxeDhcpAppendOptionNative = Uint32 Function(Pointer<Void>, Uint32, Pointer<Uint32>, Uint8, Uint8, Pointer<Void>);
typedef PxeDhcpAppendOptionDart = int Function(Pointer<Void>, int, Pointer<Uint32>, int, int, Pointer<Void>);
final PxeDhcpAppendOption = DynamicLibrary.open('WDSPXE.dll')
    .lookupFunction<PxeDhcpAppendOptionNative, PxeDhcpAppendOptionDart>('PxeDhcpAppendOption');
// pReplyPacket : void* in/out -> Pointer<Void>
// uMaxReplyPacketLen : DWORD -> Uint32
// puReplyPacketLen : DWORD* in/out -> Pointer<Uint32>
// bOption : BYTE -> Uint8
// bOptionLen : BYTE -> Uint8
// pValue : void* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function PxeDhcpAppendOption(
  pReplyPacket: Pointer;   // void* in/out
  uMaxReplyPacketLen: DWORD;   // DWORD
  puReplyPacketLen: Pointer;   // DWORD* in/out
  bOption: Byte;   // BYTE
  bOptionLen: Byte;   // BYTE
  pValue: Pointer   // void* optional
): DWORD; stdcall;
  external 'WDSPXE.dll' name 'PxeDhcpAppendOption';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "PxeDhcpAppendOption"
  c_PxeDhcpAppendOption :: Ptr () -> Word32 -> Ptr Word32 -> Word8 -> Word8 -> Ptr () -> IO Word32
-- pReplyPacket : void* in/out -> Ptr ()
-- uMaxReplyPacketLen : DWORD -> Word32
-- puReplyPacketLen : DWORD* in/out -> Ptr Word32
-- bOption : BYTE -> Word8
-- bOptionLen : BYTE -> Word8
-- pValue : void* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let pxedhcpappendoption =
  foreign "PxeDhcpAppendOption"
    ((ptr void) @-> uint32_t @-> (ptr uint32_t) @-> uint8_t @-> uint8_t @-> (ptr void) @-> returning uint32_t)
(* pReplyPacket : void* in/out -> (ptr void) *)
(* uMaxReplyPacketLen : DWORD -> uint32_t *)
(* puReplyPacketLen : DWORD* in/out -> (ptr uint32_t) *)
(* bOption : BYTE -> uint8_t *)
(* bOptionLen : BYTE -> uint8_t *)
(* pValue : void* optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library wdspxe (t "WDSPXE.dll"))
(cffi:use-foreign-library wdspxe)

(cffi:defcfun ("PxeDhcpAppendOption" pxe-dhcp-append-option :convention :stdcall) :uint32
  (p-reply-packet :pointer)   ; void* in/out
  (u-max-reply-packet-len :uint32)   ; DWORD
  (pu-reply-packet-len :pointer)   ; DWORD* in/out
  (b-option :uint8)   ; BYTE
  (b-option-len :uint8)   ; BYTE
  (p-value :pointer))   ; void* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $PxeDhcpAppendOption = Win32::API::More->new('WDSPXE',
    'DWORD PxeDhcpAppendOption(LPVOID pReplyPacket, DWORD uMaxReplyPacketLen, LPVOID puReplyPacketLen, BYTE bOption, BYTE bOptionLen, LPVOID pValue)');
# my $ret = $PxeDhcpAppendOption->Call($pReplyPacket, $uMaxReplyPacketLen, $puReplyPacketLen, $bOption, $bOptionLen, $pValue);
# pReplyPacket : void* in/out -> LPVOID
# uMaxReplyPacketLen : DWORD -> DWORD
# puReplyPacketLen : DWORD* in/out -> LPVOID
# bOption : BYTE -> BYTE
# bOptionLen : BYTE -> BYTE
# pValue : void* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。