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

NdrClientContextMarshall

関数
NDRでクライアント側コンテキストハンドルをマーシャリングする。
DLLRPCRT4.dll呼出規約winapi

シグネチャ

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

void NdrClientContextMarshall(
    MIDL_STUB_MESSAGE* pStubMsg,
    INT_PTR ContextHandle,
    INT fCheck
);

パラメーター

名前方向
pStubMsgMIDL_STUB_MESSAGE*inout
ContextHandleINT_PTRin
fCheckINTin

戻り値の型: void

各言語での呼び出し定義

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

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

NdrClientContextMarshall = ctypes.windll.rpcrt4.NdrClientContextMarshall
NdrClientContextMarshall.restype = None
NdrClientContextMarshall.argtypes = [
    ctypes.c_void_p,  # pStubMsg : MIDL_STUB_MESSAGE* in/out
    ctypes.c_ssize_t,  # ContextHandle : INT_PTR
    ctypes.c_int,  # fCheck : INT
]
require 'fiddle'
require 'fiddle/import'

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

var (
	rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
	procNdrClientContextMarshall = rpcrt4.NewProc("NdrClientContextMarshall")
)

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