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

NDRSContextMarshall

関数
サーバーコンテキストハンドルをバッファにマーシャリングする。
DLLRPCRT4.dll呼出規約winapi

シグネチャ

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

void NDRSContextMarshall(
    NDR_SCONTEXT* CContext,
    void* pBuff,
    NDR_RUNDOWN userRunDownIn
);

パラメーター

名前方向
CContextNDR_SCONTEXT*in
pBuffvoid*out
userRunDownInNDR_RUNDOWNin

戻り値の型: void

各言語での呼び出し定義

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

void NDRSContextMarshall(
    NDR_SCONTEXT* CContext,
    void* pBuff,
    NDR_RUNDOWN userRunDownIn
);
[DllImport("RPCRT4.dll", ExactSpelling = true)]
static extern void NDRSContextMarshall(
    IntPtr CContext,   // NDR_SCONTEXT*
    IntPtr pBuff,   // void* out
    IntPtr userRunDownIn   // NDR_RUNDOWN
);
<DllImport("RPCRT4.dll", ExactSpelling:=True)>
Public Shared Sub NDRSContextMarshall(
    CContext As IntPtr,   ' NDR_SCONTEXT*
    pBuff As IntPtr,   ' void* out
    userRunDownIn As IntPtr   ' NDR_RUNDOWN
)
End Sub
' CContext : NDR_SCONTEXT*
' pBuff : void* out
' userRunDownIn : NDR_RUNDOWN
Declare PtrSafe Sub NDRSContextMarshall Lib "rpcrt4" ( _
    ByVal CContext As LongPtr, _
    ByVal pBuff As LongPtr, _
    ByVal userRunDownIn As LongPtr)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

NDRSContextMarshall = ctypes.windll.rpcrt4.NDRSContextMarshall
NDRSContextMarshall.restype = None
NDRSContextMarshall.argtypes = [
    ctypes.c_void_p,  # CContext : NDR_SCONTEXT*
    ctypes.POINTER(None),  # pBuff : void* out
    ctypes.c_void_p,  # userRunDownIn : NDR_RUNDOWN
]
require 'fiddle'
require 'fiddle/import'

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

var (
	rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
	procNDRSContextMarshall = rpcrt4.NewProc("NDRSContextMarshall")
)

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