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

NdrGetDcomProtocolVersion

関数
DCOMのプロトコルバージョンを取得する。
DLLRPCRT4.dll呼出規約winapi

シグネチャ

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

HRESULT NdrGetDcomProtocolVersion(
    MIDL_STUB_MESSAGE* pStubMsg,
    RPC_VERSION* pVersion
);

パラメーター

名前方向
pStubMsgMIDL_STUB_MESSAGE*inout
pVersionRPC_VERSION*inout

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

NdrGetDcomProtocolVersion = ctypes.windll.rpcrt4.NdrGetDcomProtocolVersion
NdrGetDcomProtocolVersion.restype = ctypes.c_int
NdrGetDcomProtocolVersion.argtypes = [
    ctypes.c_void_p,  # pStubMsg : MIDL_STUB_MESSAGE* in/out
    ctypes.c_void_p,  # pVersion : RPC_VERSION* in/out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
	procNdrGetDcomProtocolVersion = rpcrt4.NewProc("NdrGetDcomProtocolVersion")
)

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