RpcEpRegisterA
関数シグネチャ
// RPCRT4.dll (ANSI / -A)
#include <windows.h>
RPC_STATUS RpcEpRegisterA(
void* IfSpec,
RPC_BINDING_VECTOR* BindingVector,
UUID_VECTOR* UuidVector, // optional
LPSTR Annotation // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| IfSpec | void* | in | ローカルのエンドポイントマップデータベースに登録するインターフェイス。 |
| BindingVector | RPC_BINDING_VECTOR* | in | サーバーがリモートプロシージャコールを受信できるバインドハンドルのベクターへのポインター。 |
| UuidVector | UUID_VECTOR* | inoptional | サーバーが提供するオブジェクト UUID のベクターへのポインター。このベクターはサーバーアプリケーションが構築します。null を指定した場合は、登録するオブジェクト UUID がないことを示します。 |
| Annotation | LPSTR | inoptional | ローカルのエンドポイントマップデータベースに追加される各直積要素に適用される、文字列コメントへのポインター。文字列は null 終端文字を含めて最大 64 文字です。注釈文字列がない場合は、null 値または null 終端文字列 ("\0") を指定します。 注釈文字列はアプリケーションが情報として利用するだけのものです。RPC はこの文字列を、クライアントがどのサーバーインスタンスと通信するかの判定や、エンドポイントマップデータベース内の要素の列挙には使用しません。 |
戻り値の型: RPC_STATUS
公式ドキュメント
RpcEpRegister 関数は、ローカルのエンドポイントマップデータベースにサーバーのアドレス情報を追加、または置き換えます。(RpcEpRegisterA)
戻り値
| 値 | 意味 |
|---|---|
| 呼び出しが成功しました。 | |
| バインドがありません。 | |
| バインドハンドルが無効です。 | |
| この操作に対して不適切な種類のバインドです。 |
解説(Remarks)
RpcEpRegister 関数は、ローカルホストのエンドポイントマップデータベースにエントリを追加、または置き換えます。指定されたインターフェイス仕様、バインドハンドル、オブジェクト UUID に一致する既存のデータベースエントリがある場合、この関数はそのエントリのエンドポイントを、指定されたバインドハンドル内のエンドポイントで置き換えます。
サーバーは RpcEpRegister と RpcEpRegisterNoReplace を使用して、エンドポイントマッパーデータベースにエントリを登録できます。Windows 2000 より前は、既に動作していない以前のサーバーインスタンスが残した古いエントリをサーバーが上書きできるように、2 つの関数が用意されていました。現在は、サーバーインスタンスが登録したエントリは、そのサーバーが動作を停止した時点でエンドポイントマッパーデータベースから自動的に削除されます。ただし、セキュリティ上の理由から、サーバーが別のサーバーのエンドポイントマッパーエントリを置き換えることは許可されていません。したがって、RpcEpRegister と RpcEpRegisterNoReplace はほぼ同じ機能を実行します。
サーバーアプリケーションは、次のいずれかの関数を呼び出して指定したエンドポイントを登録するために、 RpcEpRegister を呼び出します。
- RpcServerUseAllProtseqs
- RpcServerUseProtseq
- RpcServerUseProtseqEp
- RpcServerUseAllProtseqsIf
- RpcServerUseProtseqIf
エンドポイントを指定せずにプロトコルシーケンスを使用した場合、RPC ランタイムライブラリは動的エンドポイントを自動的に生成します。この場合、サーバーは RpcServerInqBindings を呼び出した後に RpcEpRegister を呼び出すことで、複数のクライアントから利用できるようになります。そうしない場合、自動的に開始されたサーバーは、そのサーバーを開始させたクライアントからのみ認識されます。エンドポイントマップデータベースに追加される各要素は、論理的に次の情報を含みます。
- インターフェイス UUID
- インターフェイスのバージョン (メジャーおよびマイナー)
- バインドハンドル
- オブジェクト UUID (省略可能)
- 注釈 (省略可能)
rpcdce.h ヘッダーは、UNICODE プリプロセッサ定数の定義に応じてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして RpcEpRegister を定義します。エンコーディング中立なエイリアスの使用と、エンコーディング中立でないコードを混在させると、不一致が生じてコンパイルエラーや実行時エラーの原因となることがあります。詳細については、Conventions for Function Prototypes を参照してください。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// RPCRT4.dll (ANSI / -A)
#include <windows.h>
RPC_STATUS RpcEpRegisterA(
void* IfSpec,
RPC_BINDING_VECTOR* BindingVector,
UUID_VECTOR* UuidVector, // optional
LPSTR Annotation // optional
);[DllImport("RPCRT4.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int RpcEpRegisterA(
IntPtr IfSpec, // void*
IntPtr BindingVector, // RPC_BINDING_VECTOR*
IntPtr UuidVector, // UUID_VECTOR* optional
[MarshalAs(UnmanagedType.LPStr)] string Annotation // LPSTR optional
);<DllImport("RPCRT4.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function RpcEpRegisterA(
IfSpec As IntPtr, ' void*
BindingVector As IntPtr, ' RPC_BINDING_VECTOR*
UuidVector As IntPtr, ' UUID_VECTOR* optional
<MarshalAs(UnmanagedType.LPStr)> Annotation As String ' LPSTR optional
) As Integer
End Function' IfSpec : void*
' BindingVector : RPC_BINDING_VECTOR*
' UuidVector : UUID_VECTOR* optional
' Annotation : LPSTR optional
Declare PtrSafe Function RpcEpRegisterA Lib "rpcrt4" ( _
ByVal IfSpec As LongPtr, _
ByVal BindingVector As LongPtr, _
ByVal UuidVector As LongPtr, _
ByVal Annotation As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RpcEpRegisterA = ctypes.windll.rpcrt4.RpcEpRegisterA
RpcEpRegisterA.restype = ctypes.c_int
RpcEpRegisterA.argtypes = [
ctypes.POINTER(None), # IfSpec : void*
ctypes.c_void_p, # BindingVector : RPC_BINDING_VECTOR*
ctypes.c_void_p, # UuidVector : UUID_VECTOR* optional
wintypes.LPCSTR, # Annotation : LPSTR optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('RPCRT4.dll')
RpcEpRegisterA = Fiddle::Function.new(
lib['RpcEpRegisterA'],
[
Fiddle::TYPE_VOIDP, # IfSpec : void*
Fiddle::TYPE_VOIDP, # BindingVector : RPC_BINDING_VECTOR*
Fiddle::TYPE_VOIDP, # UuidVector : UUID_VECTOR* optional
Fiddle::TYPE_VOIDP, # Annotation : LPSTR optional
],
Fiddle::TYPE_INT)#[link(name = "rpcrt4")]
extern "system" {
fn RpcEpRegisterA(
IfSpec: *mut (), // void*
BindingVector: *mut RPC_BINDING_VECTOR, // RPC_BINDING_VECTOR*
UuidVector: *mut UUID_VECTOR, // UUID_VECTOR* optional
Annotation: *mut u8 // LPSTR optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("RPCRT4.dll", CharSet = CharSet.Ansi)]
public static extern int RpcEpRegisterA(IntPtr IfSpec, IntPtr BindingVector, IntPtr UuidVector, [MarshalAs(UnmanagedType.LPStr)] string Annotation);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RPCRT4_RpcEpRegisterA' -Namespace Win32 -PassThru
# $api::RpcEpRegisterA(IfSpec, BindingVector, UuidVector, Annotation)#uselib "RPCRT4.dll"
#func global RpcEpRegisterA "RpcEpRegisterA" sptr, sptr, sptr, sptr
; RpcEpRegisterA IfSpec, varptr(BindingVector), varptr(UuidVector), Annotation ; 戻り値は stat
; IfSpec : void* -> "sptr"
; BindingVector : RPC_BINDING_VECTOR* -> "sptr"
; UuidVector : UUID_VECTOR* optional -> "sptr"
; Annotation : LPSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "RPCRT4.dll" #cfunc global RpcEpRegisterA "RpcEpRegisterA" sptr, var, var, str ; res = RpcEpRegisterA(IfSpec, BindingVector, UuidVector, Annotation) ; IfSpec : void* -> "sptr" ; BindingVector : RPC_BINDING_VECTOR* -> "var" ; UuidVector : UUID_VECTOR* optional -> "var" ; Annotation : LPSTR optional -> "str" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "RPCRT4.dll" #cfunc global RpcEpRegisterA "RpcEpRegisterA" sptr, sptr, sptr, str ; res = RpcEpRegisterA(IfSpec, varptr(BindingVector), varptr(UuidVector), Annotation) ; IfSpec : void* -> "sptr" ; BindingVector : RPC_BINDING_VECTOR* -> "sptr" ; UuidVector : UUID_VECTOR* optional -> "sptr" ; Annotation : LPSTR optional -> "str" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
; RPC_STATUS RpcEpRegisterA(void* IfSpec, RPC_BINDING_VECTOR* BindingVector, UUID_VECTOR* UuidVector, LPSTR Annotation) #uselib "RPCRT4.dll" #cfunc global RpcEpRegisterA "RpcEpRegisterA" intptr, var, var, str ; res = RpcEpRegisterA(IfSpec, BindingVector, UuidVector, Annotation) ; IfSpec : void* -> "intptr" ; BindingVector : RPC_BINDING_VECTOR* -> "var" ; UuidVector : UUID_VECTOR* optional -> "var" ; Annotation : LPSTR optional -> "str" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; RPC_STATUS RpcEpRegisterA(void* IfSpec, RPC_BINDING_VECTOR* BindingVector, UUID_VECTOR* UuidVector, LPSTR Annotation) #uselib "RPCRT4.dll" #cfunc global RpcEpRegisterA "RpcEpRegisterA" intptr, intptr, intptr, str ; res = RpcEpRegisterA(IfSpec, varptr(BindingVector), varptr(UuidVector), Annotation) ; IfSpec : void* -> "intptr" ; BindingVector : RPC_BINDING_VECTOR* -> "intptr" ; UuidVector : UUID_VECTOR* optional -> "intptr" ; Annotation : LPSTR optional -> "str" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
procRpcEpRegisterA = rpcrt4.NewProc("RpcEpRegisterA")
)
// IfSpec (void*), BindingVector (RPC_BINDING_VECTOR*), UuidVector (UUID_VECTOR* optional), Annotation (LPSTR optional)
r1, _, err := procRpcEpRegisterA.Call(
uintptr(IfSpec),
uintptr(BindingVector),
uintptr(UuidVector),
uintptr(unsafe.Pointer(windows.BytePtrFromString(Annotation))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // RPC_STATUSfunction RpcEpRegisterA(
IfSpec: Pointer; // void*
BindingVector: Pointer; // RPC_BINDING_VECTOR*
UuidVector: Pointer; // UUID_VECTOR* optional
Annotation: PAnsiChar // LPSTR optional
): Integer; stdcall;
external 'RPCRT4.dll' name 'RpcEpRegisterA';result := DllCall("RPCRT4\RpcEpRegisterA"
, "Ptr", IfSpec ; void*
, "Ptr", BindingVector ; RPC_BINDING_VECTOR*
, "Ptr", UuidVector ; UUID_VECTOR* optional
, "AStr", Annotation ; LPSTR optional
, "Int") ; return: RPC_STATUS●RpcEpRegisterA(IfSpec, BindingVector, UuidVector, Annotation) = DLL("RPCRT4.dll", "int RpcEpRegisterA(void*, void*, void*, char*)")
# 呼び出し: RpcEpRegisterA(IfSpec, BindingVector, UuidVector, Annotation)
# IfSpec : void* -> "void*"
# BindingVector : RPC_BINDING_VECTOR* -> "void*"
# UuidVector : UUID_VECTOR* optional -> "void*"
# Annotation : LPSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "rpcrt4" fn RpcEpRegisterA(
IfSpec: ?*anyopaque, // void*
BindingVector: [*c]RPC_BINDING_VECTOR, // RPC_BINDING_VECTOR*
UuidVector: [*c]UUID_VECTOR, // UUID_VECTOR* optional
Annotation: [*c]const u8 // LPSTR optional
) callconv(std.os.windows.WINAPI) i32;proc RpcEpRegisterA(
IfSpec: pointer, # void*
BindingVector: ptr RPC_BINDING_VECTOR, # RPC_BINDING_VECTOR*
UuidVector: ptr UUID_VECTOR, # UUID_VECTOR* optional
Annotation: cstring # LPSTR optional
): int32 {.importc: "RpcEpRegisterA", stdcall, dynlib: "RPCRT4.dll".}pragma(lib, "rpcrt4");
extern(Windows)
int RpcEpRegisterA(
void* IfSpec, // void*
RPC_BINDING_VECTOR* BindingVector, // RPC_BINDING_VECTOR*
UUID_VECTOR* UuidVector, // UUID_VECTOR* optional
const(char)* Annotation // LPSTR optional
);ccall((:RpcEpRegisterA, "RPCRT4.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{RPC_BINDING_VECTOR}, Ptr{UUID_VECTOR}, Cstring),
IfSpec, BindingVector, UuidVector, Annotation)
# IfSpec : void* -> Ptr{Cvoid}
# BindingVector : RPC_BINDING_VECTOR* -> Ptr{RPC_BINDING_VECTOR}
# UuidVector : UUID_VECTOR* optional -> Ptr{UUID_VECTOR}
# Annotation : LPSTR optional -> Cstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t RpcEpRegisterA(
void* IfSpec,
void* BindingVector,
void* UuidVector,
const char* Annotation);
]]
local rpcrt4 = ffi.load("rpcrt4")
-- rpcrt4.RpcEpRegisterA(IfSpec, BindingVector, UuidVector, Annotation)
-- IfSpec : void*
-- BindingVector : RPC_BINDING_VECTOR*
-- UuidVector : UUID_VECTOR* optional
-- Annotation : LPSTR optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('RPCRT4.dll');
const RpcEpRegisterA = lib.func('__stdcall', 'RpcEpRegisterA', 'int32_t', ['void *', 'void *', 'void *', 'str']);
// RpcEpRegisterA(IfSpec, BindingVector, UuidVector, Annotation)
// IfSpec : void* -> 'void *'
// BindingVector : RPC_BINDING_VECTOR* -> 'void *'
// UuidVector : UUID_VECTOR* optional -> 'void *'
// Annotation : LPSTR optional -> 'str'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("RPCRT4.dll", {
RpcEpRegisterA: { parameters: ["pointer", "pointer", "pointer", "buffer"], result: "i32" },
});
// lib.symbols.RpcEpRegisterA(IfSpec, BindingVector, UuidVector, Annotation)
// IfSpec : void* -> "pointer"
// BindingVector : RPC_BINDING_VECTOR* -> "pointer"
// UuidVector : UUID_VECTOR* optional -> "pointer"
// Annotation : LPSTR optional -> "buffer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t RpcEpRegisterA(
void* IfSpec,
void* BindingVector,
void* UuidVector,
const char* Annotation);
C, "RPCRT4.dll");
// $ffi->RpcEpRegisterA(IfSpec, BindingVector, UuidVector, Annotation);
// IfSpec : void*
// BindingVector : RPC_BINDING_VECTOR*
// UuidVector : UUID_VECTOR* optional
// Annotation : LPSTR optional
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Rpcrt4 extends StdCallLibrary {
Rpcrt4 INSTANCE = Native.load("rpcrt4", Rpcrt4.class, W32APIOptions.ASCII_OPTIONS);
int RpcEpRegisterA(
Pointer IfSpec, // void*
Pointer BindingVector, // RPC_BINDING_VECTOR*
Pointer UuidVector, // UUID_VECTOR* optional
String Annotation // LPSTR optional
);
}@[Link("rpcrt4")]
lib LibRPCRT4
fun RpcEpRegisterA = RpcEpRegisterA(
IfSpec : Void*, # void*
BindingVector : RPC_BINDING_VECTOR*, # RPC_BINDING_VECTOR*
UuidVector : UUID_VECTOR*, # UUID_VECTOR* optional
Annotation : UInt8* # LPSTR optional
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef RpcEpRegisterANative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Utf8>);
typedef RpcEpRegisterADart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Utf8>);
final RpcEpRegisterA = DynamicLibrary.open('RPCRT4.dll')
.lookupFunction<RpcEpRegisterANative, RpcEpRegisterADart>('RpcEpRegisterA');
// IfSpec : void* -> Pointer<Void>
// BindingVector : RPC_BINDING_VECTOR* -> Pointer<Void>
// UuidVector : UUID_VECTOR* optional -> Pointer<Void>
// Annotation : LPSTR optional -> Pointer<Utf8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function RpcEpRegisterA(
IfSpec: Pointer; // void*
BindingVector: Pointer; // RPC_BINDING_VECTOR*
UuidVector: Pointer; // UUID_VECTOR* optional
Annotation: PAnsiChar // LPSTR optional
): Integer; stdcall;
external 'RPCRT4.dll' name 'RpcEpRegisterA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RpcEpRegisterA"
c_RpcEpRegisterA :: Ptr () -> Ptr () -> Ptr () -> CString -> IO Int32
-- IfSpec : void* -> Ptr ()
-- BindingVector : RPC_BINDING_VECTOR* -> Ptr ()
-- UuidVector : UUID_VECTOR* optional -> Ptr ()
-- Annotation : LPSTR optional -> CString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let rpcepregistera =
foreign "RpcEpRegisterA"
((ptr void) @-> (ptr void) @-> (ptr void) @-> string @-> returning int32_t)
(* IfSpec : void* -> (ptr void) *)
(* BindingVector : RPC_BINDING_VECTOR* -> (ptr void) *)
(* UuidVector : UUID_VECTOR* optional -> (ptr void) *)
(* Annotation : LPSTR optional -> string *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library rpcrt4 (t "RPCRT4.dll"))
(cffi:use-foreign-library rpcrt4)
(cffi:defcfun ("RpcEpRegisterA" rpc-ep-register-a :convention :stdcall) :int32
(if-spec :pointer) ; void*
(binding-vector :pointer) ; RPC_BINDING_VECTOR*
(uuid-vector :pointer) ; UUID_VECTOR* optional
(annotation :string)) ; LPSTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RpcEpRegisterA = Win32::API::More->new('RPCRT4',
'int RpcEpRegisterA(LPVOID IfSpec, LPVOID BindingVector, LPVOID UuidVector, LPCSTR Annotation)');
# my $ret = $RpcEpRegisterA->Call($IfSpec, $BindingVector, $UuidVector, $Annotation);
# IfSpec : void* -> LPVOID
# BindingVector : RPC_BINDING_VECTOR* -> LPVOID
# UuidVector : UUID_VECTOR* optional -> LPVOID
# Annotation : LPSTR optional -> LPCSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
- f RpcEpRegisterW (Unicode版) — RPCインターフェイスのバインディングをエンドポイントマッパーへ登録する(Unicode版)。
- f RpcEpUnregister — エンドポイントマッパーからRPCインターフェイスの登録を解除する。
- f RpcNsBindingExportA — ネームサービスにインターフェイスのバインディングをエクスポートする(ANSI版)。
- f RpcServerInqBindings — サーバーのバインディングベクターを取得する。
- f RpcServerUseAllProtseqs — 利用可能な全プロトコルシーケンスを使用登録する。
- f RpcServerUseAllProtseqsIf — インターフェイス指定で全プロトコルシーケンスを登録する。