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

NdrSimpleTypeMarshall

関数
NDRで単純型データをバッファにマーシャリングする。
DLLRPCRT4.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

void NdrSimpleTypeMarshall(
    MIDL_STUB_MESSAGE* pStubMsg,
    BYTE* pMemory,
    BYTE FormatChar
);

パラメーター

名前方向
pStubMsgMIDL_STUB_MESSAGE*inout
pMemoryBYTE*inout
FormatCharBYTEin

戻り値の型: void

各言語での呼び出し定義

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

void NdrSimpleTypeMarshall(
    MIDL_STUB_MESSAGE* pStubMsg,
    BYTE* pMemory,
    BYTE FormatChar
);
[DllImport("RPCRT4.dll", ExactSpelling = true)]
static extern void NdrSimpleTypeMarshall(
    IntPtr pStubMsg,   // MIDL_STUB_MESSAGE* in/out
    IntPtr pMemory,   // BYTE* in/out
    byte FormatChar   // BYTE
);
<DllImport("RPCRT4.dll", ExactSpelling:=True)>
Public Shared Sub NdrSimpleTypeMarshall(
    pStubMsg As IntPtr,   ' MIDL_STUB_MESSAGE* in/out
    pMemory As IntPtr,   ' BYTE* in/out
    FormatChar As Byte   ' BYTE
)
End Sub
' pStubMsg : MIDL_STUB_MESSAGE* in/out
' pMemory : BYTE* in/out
' FormatChar : BYTE
Declare PtrSafe Sub NdrSimpleTypeMarshall Lib "rpcrt4" ( _
    ByVal pStubMsg As LongPtr, _
    ByVal pMemory As LongPtr, _
    ByVal FormatChar As Byte)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

NdrSimpleTypeMarshall = ctypes.windll.rpcrt4.NdrSimpleTypeMarshall
NdrSimpleTypeMarshall.restype = None
NdrSimpleTypeMarshall.argtypes = [
    ctypes.c_void_p,  # pStubMsg : MIDL_STUB_MESSAGE* in/out
    ctypes.POINTER(ctypes.c_ubyte),  # pMemory : BYTE* in/out
    ctypes.c_ubyte,  # FormatChar : BYTE
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('RPCRT4.dll')
NdrSimpleTypeMarshall = Fiddle::Function.new(
  lib['NdrSimpleTypeMarshall'],
  [
    Fiddle::TYPE_VOIDP,  # pStubMsg : MIDL_STUB_MESSAGE* in/out
    Fiddle::TYPE_VOIDP,  # pMemory : BYTE* in/out
    -Fiddle::TYPE_CHAR,  # FormatChar : BYTE
  ],
  Fiddle::TYPE_VOID)
#[link(name = "rpcrt4")]
extern "system" {
    fn NdrSimpleTypeMarshall(
        pStubMsg: *mut MIDL_STUB_MESSAGE,  // MIDL_STUB_MESSAGE* in/out
        pMemory: *mut u8,  // BYTE* in/out
        FormatChar: u8  // BYTE
    );
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("RPCRT4.dll")]
public static extern void NdrSimpleTypeMarshall(IntPtr pStubMsg, IntPtr pMemory, byte FormatChar);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RPCRT4_NdrSimpleTypeMarshall' -Namespace Win32 -PassThru
# $api::NdrSimpleTypeMarshall(pStubMsg, pMemory, FormatChar)
#uselib "RPCRT4.dll"
#func global NdrSimpleTypeMarshall "NdrSimpleTypeMarshall" sptr, sptr, sptr
; NdrSimpleTypeMarshall varptr(pStubMsg), varptr(pMemory), FormatChar
; pStubMsg : MIDL_STUB_MESSAGE* in/out -> "sptr"
; pMemory : BYTE* in/out -> "sptr"
; FormatChar : BYTE -> "sptr"
出力引数:
#uselib "RPCRT4.dll"
#func global NdrSimpleTypeMarshall "NdrSimpleTypeMarshall" var, var, int
; NdrSimpleTypeMarshall pStubMsg, pMemory, FormatChar
; pStubMsg : MIDL_STUB_MESSAGE* in/out -> "var"
; pMemory : BYTE* in/out -> "var"
; FormatChar : BYTE -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; void NdrSimpleTypeMarshall(MIDL_STUB_MESSAGE* pStubMsg, BYTE* pMemory, BYTE FormatChar)
#uselib "RPCRT4.dll"
#func global NdrSimpleTypeMarshall "NdrSimpleTypeMarshall" var, var, int
; NdrSimpleTypeMarshall pStubMsg, pMemory, FormatChar
; pStubMsg : MIDL_STUB_MESSAGE* in/out -> "var"
; pMemory : BYTE* in/out -> "var"
; FormatChar : BYTE -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
	procNdrSimpleTypeMarshall = rpcrt4.NewProc("NdrSimpleTypeMarshall")
)

// pStubMsg (MIDL_STUB_MESSAGE* in/out), pMemory (BYTE* in/out), FormatChar (BYTE)
r1, _, err := procNdrSimpleTypeMarshall.Call(
	uintptr(pStubMsg),
	uintptr(pMemory),
	uintptr(FormatChar),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // void
procedure NdrSimpleTypeMarshall(
  pStubMsg: Pointer;   // MIDL_STUB_MESSAGE* in/out
  pMemory: Pointer;   // BYTE* in/out
  FormatChar: Byte   // BYTE
); stdcall;
  external 'RPCRT4.dll' name 'NdrSimpleTypeMarshall';
result := DllCall("RPCRT4\NdrSimpleTypeMarshall"
    , "Ptr", pStubMsg   ; MIDL_STUB_MESSAGE* in/out
    , "Ptr", pMemory   ; BYTE* in/out
    , "UChar", FormatChar   ; BYTE
    , "Int")   ; return: void
●NdrSimpleTypeMarshall(pStubMsg, pMemory, FormatChar) = DLL("RPCRT4.dll", "int NdrSimpleTypeMarshall(void*, void*, byte)")
# 呼び出し: NdrSimpleTypeMarshall(pStubMsg, pMemory, FormatChar)
# pStubMsg : MIDL_STUB_MESSAGE* in/out -> "void*"
# pMemory : BYTE* in/out -> "void*"
# FormatChar : BYTE -> "byte"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。