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

PxeDhcpAppendOptionRaw

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

シグネチャ

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

DWORD PxeDhcpAppendOptionRaw(
    void* pReplyPacket,
    DWORD uMaxReplyPacketLen,
    DWORD* puReplyPacketLen,
    WORD uBufferLen,
    void* pBuffer
);

パラメーター

名前方向
pReplyPacketvoid*inout
uMaxReplyPacketLenDWORDin
puReplyPacketLenDWORD*inout
uBufferLenWORDin
pBuffervoid*in

戻り値の型: DWORD

各言語での呼び出し定義

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

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

PxeDhcpAppendOptionRaw = ctypes.windll.wdspxe.PxeDhcpAppendOptionRaw
PxeDhcpAppendOptionRaw.restype = wintypes.DWORD
PxeDhcpAppendOptionRaw.argtypes = [
    ctypes.POINTER(None),  # pReplyPacket : void* in/out
    wintypes.DWORD,  # uMaxReplyPacketLen : DWORD
    ctypes.POINTER(wintypes.DWORD),  # puReplyPacketLen : DWORD* in/out
    ctypes.c_ushort,  # uBufferLen : WORD
    ctypes.POINTER(None),  # pBuffer : void*
]
require 'fiddle'
require 'fiddle/import'

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

var (
	wdspxe = windows.NewLazySystemDLL("WDSPXE.dll")
	procPxeDhcpAppendOptionRaw = wdspxe.NewProc("PxeDhcpAppendOptionRaw")
)

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