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

NdrUserMarshalMemorySize

関数
NDRでユーザー定義マーシャリング型に必要なメモリサイズを算出する。
DLLRPCRT4.dll呼出規約winapi

シグネチャ

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

DWORD NdrUserMarshalMemorySize(
    MIDL_STUB_MESSAGE* pStubMsg,
    BYTE* pFormat
);

パラメーター

名前方向
pStubMsgMIDL_STUB_MESSAGE*inout
pFormatBYTE*inout

戻り値の型: DWORD

各言語での呼び出し定義

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

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

NdrUserMarshalMemorySize = ctypes.windll.rpcrt4.NdrUserMarshalMemorySize
NdrUserMarshalMemorySize.restype = wintypes.DWORD
NdrUserMarshalMemorySize.argtypes = [
    ctypes.c_void_p,  # pStubMsg : MIDL_STUB_MESSAGE* in/out
    ctypes.POINTER(ctypes.c_ubyte),  # pFormat : BYTE* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
	procNdrUserMarshalMemorySize = rpcrt4.NewProc("NdrUserMarshalMemorySize")
)

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