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

RpcEpRegisterNoReplaceW

関数
既存の登録を置き換えずにエンドポイントマッパーへRPCエンドポイントを登録する(Unicode版)。
DLLRPCRT4.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// RPCRT4.dll  (Unicode / -W)
#include <windows.h>

RPC_STATUS RpcEpRegisterNoReplaceW(
    void* IfSpec,
    RPC_BINDING_VECTOR* BindingVector,
    UUID_VECTOR* UuidVector,   // optional
    LPWSTR Annotation   // optional
);

パラメーター

名前方向説明
IfSpecvoid*inエンドポイントマッパーへ登録するインターフェイス仕様ハンドル。
BindingVectorRPC_BINDING_VECTOR*in登録するサーバーバインディング群を保持するRPC_BINDING_VECTORへのポインタ。
UuidVectorUUID_VECTOR*inoptional関連付けるオブジェクトUUID群へのポインタ。NULL可。
AnnotationLPWSTRinoptional登録に付与する注釈文字列(Unicode、最大64文字)。NULL可。

戻り値の型: RPC_STATUS

各言語での呼び出し定義

// RPCRT4.dll  (Unicode / -W)
#include <windows.h>

RPC_STATUS RpcEpRegisterNoReplaceW(
    void* IfSpec,
    RPC_BINDING_VECTOR* BindingVector,
    UUID_VECTOR* UuidVector,   // optional
    LPWSTR Annotation   // optional
);
[DllImport("RPCRT4.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int RpcEpRegisterNoReplaceW(
    IntPtr IfSpec,   // void*
    IntPtr BindingVector,   // RPC_BINDING_VECTOR*
    IntPtr UuidVector,   // UUID_VECTOR* optional
    [MarshalAs(UnmanagedType.LPWStr)] string Annotation   // LPWSTR optional
);
<DllImport("RPCRT4.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function RpcEpRegisterNoReplaceW(
    IfSpec As IntPtr,   ' void*
    BindingVector As IntPtr,   ' RPC_BINDING_VECTOR*
    UuidVector As IntPtr,   ' UUID_VECTOR* optional
    <MarshalAs(UnmanagedType.LPWStr)> Annotation As String   ' LPWSTR optional
) As Integer
End Function
' IfSpec : void*
' BindingVector : RPC_BINDING_VECTOR*
' UuidVector : UUID_VECTOR* optional
' Annotation : LPWSTR optional
Declare PtrSafe Function RpcEpRegisterNoReplaceW Lib "rpcrt4" ( _
    ByVal IfSpec As LongPtr, _
    ByVal BindingVector As LongPtr, _
    ByVal UuidVector As LongPtr, _
    ByVal Annotation As LongPtr) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RpcEpRegisterNoReplaceW = ctypes.windll.rpcrt4.RpcEpRegisterNoReplaceW
RpcEpRegisterNoReplaceW.restype = ctypes.c_int
RpcEpRegisterNoReplaceW.argtypes = [
    ctypes.POINTER(None),  # IfSpec : void*
    ctypes.c_void_p,  # BindingVector : RPC_BINDING_VECTOR*
    ctypes.c_void_p,  # UuidVector : UUID_VECTOR* optional
    wintypes.LPCWSTR,  # Annotation : LPWSTR optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('RPCRT4.dll')
RpcEpRegisterNoReplaceW = Fiddle::Function.new(
  lib['RpcEpRegisterNoReplaceW'],
  [
    Fiddle::TYPE_VOIDP,  # IfSpec : void*
    Fiddle::TYPE_VOIDP,  # BindingVector : RPC_BINDING_VECTOR*
    Fiddle::TYPE_VOIDP,  # UuidVector : UUID_VECTOR* optional
    Fiddle::TYPE_VOIDP,  # Annotation : LPWSTR optional
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "rpcrt4")]
extern "system" {
    fn RpcEpRegisterNoReplaceW(
        IfSpec: *mut (),  // void*
        BindingVector: *mut RPC_BINDING_VECTOR,  // RPC_BINDING_VECTOR*
        UuidVector: *mut UUID_VECTOR,  // UUID_VECTOR* optional
        Annotation: *mut u16  // LPWSTR optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("RPCRT4.dll", CharSet = CharSet.Unicode)]
public static extern int RpcEpRegisterNoReplaceW(IntPtr IfSpec, IntPtr BindingVector, IntPtr UuidVector, [MarshalAs(UnmanagedType.LPWStr)] string Annotation);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RPCRT4_RpcEpRegisterNoReplaceW' -Namespace Win32 -PassThru
# $api::RpcEpRegisterNoReplaceW(IfSpec, BindingVector, UuidVector, Annotation)
#uselib "RPCRT4.dll"
#func global RpcEpRegisterNoReplaceW "RpcEpRegisterNoReplaceW" wptr, wptr, wptr, wptr
; RpcEpRegisterNoReplaceW IfSpec, varptr(BindingVector), varptr(UuidVector), Annotation   ; 戻り値は stat
; IfSpec : void* -> "wptr"
; BindingVector : RPC_BINDING_VECTOR* -> "wptr"
; UuidVector : UUID_VECTOR* optional -> "wptr"
; Annotation : LPWSTR optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "RPCRT4.dll"
#cfunc global RpcEpRegisterNoReplaceW "RpcEpRegisterNoReplaceW" sptr, var, var, wstr
; res = RpcEpRegisterNoReplaceW(IfSpec, BindingVector, UuidVector, Annotation)
; IfSpec : void* -> "sptr"
; BindingVector : RPC_BINDING_VECTOR* -> "var"
; UuidVector : UUID_VECTOR* optional -> "var"
; Annotation : LPWSTR optional -> "wstr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; RPC_STATUS RpcEpRegisterNoReplaceW(void* IfSpec, RPC_BINDING_VECTOR* BindingVector, UUID_VECTOR* UuidVector, LPWSTR Annotation)
#uselib "RPCRT4.dll"
#cfunc global RpcEpRegisterNoReplaceW "RpcEpRegisterNoReplaceW" intptr, var, var, wstr
; res = RpcEpRegisterNoReplaceW(IfSpec, BindingVector, UuidVector, Annotation)
; IfSpec : void* -> "intptr"
; BindingVector : RPC_BINDING_VECTOR* -> "var"
; UuidVector : UUID_VECTOR* optional -> "var"
; Annotation : LPWSTR optional -> "wstr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
	procRpcEpRegisterNoReplaceW = rpcrt4.NewProc("RpcEpRegisterNoReplaceW")
)

// IfSpec (void*), BindingVector (RPC_BINDING_VECTOR*), UuidVector (UUID_VECTOR* optional), Annotation (LPWSTR optional)
r1, _, err := procRpcEpRegisterNoReplaceW.Call(
	uintptr(IfSpec),
	uintptr(BindingVector),
	uintptr(UuidVector),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(Annotation))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // RPC_STATUS
function RpcEpRegisterNoReplaceW(
  IfSpec: Pointer;   // void*
  BindingVector: Pointer;   // RPC_BINDING_VECTOR*
  UuidVector: Pointer;   // UUID_VECTOR* optional
  Annotation: PWideChar   // LPWSTR optional
): Integer; stdcall;
  external 'RPCRT4.dll' name 'RpcEpRegisterNoReplaceW';
result := DllCall("RPCRT4\RpcEpRegisterNoReplaceW"
    , "Ptr", IfSpec   ; void*
    , "Ptr", BindingVector   ; RPC_BINDING_VECTOR*
    , "Ptr", UuidVector   ; UUID_VECTOR* optional
    , "WStr", Annotation   ; LPWSTR optional
    , "Int")   ; return: RPC_STATUS
●RpcEpRegisterNoReplaceW(IfSpec, BindingVector, UuidVector, Annotation) = DLL("RPCRT4.dll", "int RpcEpRegisterNoReplaceW(void*, void*, void*, char*)")
# 呼び出し: RpcEpRegisterNoReplaceW(IfSpec, BindingVector, UuidVector, Annotation)
# IfSpec : void* -> "void*"
# BindingVector : RPC_BINDING_VECTOR* -> "void*"
# UuidVector : UUID_VECTOR* optional -> "void*"
# Annotation : LPWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。
const std = @import("std");

extern "rpcrt4" fn RpcEpRegisterNoReplaceW(
    IfSpec: ?*anyopaque, // void*
    BindingVector: [*c]RPC_BINDING_VECTOR, // RPC_BINDING_VECTOR*
    UuidVector: [*c]UUID_VECTOR, // UUID_VECTOR* optional
    Annotation: [*c]const u16 // LPWSTR optional
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。
proc RpcEpRegisterNoReplaceW(
    IfSpec: pointer,  # void*
    BindingVector: ptr RPC_BINDING_VECTOR,  # RPC_BINDING_VECTOR*
    UuidVector: ptr UUID_VECTOR,  # UUID_VECTOR* optional
    Annotation: WideCString  # LPWSTR optional
): int32 {.importc: "RpcEpRegisterNoReplaceW", stdcall, dynlib: "RPCRT4.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。
pragma(lib, "rpcrt4");
extern(Windows)
int RpcEpRegisterNoReplaceW(
    void* IfSpec,   // void*
    RPC_BINDING_VECTOR* BindingVector,   // RPC_BINDING_VECTOR*
    UUID_VECTOR* UuidVector,   // UUID_VECTOR* optional
    const(wchar)* Annotation   // LPWSTR optional
);
ccall((:RpcEpRegisterNoReplaceW, "RPCRT4.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Ptr{RPC_BINDING_VECTOR}, Ptr{UUID_VECTOR}, Cwstring),
      IfSpec, BindingVector, UuidVector, Annotation)
# IfSpec : void* -> Ptr{Cvoid}
# BindingVector : RPC_BINDING_VECTOR* -> Ptr{RPC_BINDING_VECTOR}
# UuidVector : UUID_VECTOR* optional -> Ptr{UUID_VECTOR}
# Annotation : LPWSTR optional -> Cwstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。
local ffi = require("ffi")
ffi.cdef[[
int32_t RpcEpRegisterNoReplaceW(
    void* IfSpec,
    void* BindingVector,
    void* UuidVector,
    const uint16_t* Annotation);
]]
local rpcrt4 = ffi.load("rpcrt4")
-- rpcrt4.RpcEpRegisterNoReplaceW(IfSpec, BindingVector, UuidVector, Annotation)
-- IfSpec : void*
-- BindingVector : RPC_BINDING_VECTOR*
-- UuidVector : UUID_VECTOR* optional
-- Annotation : LPWSTR optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。
const koffi = require('koffi');
const lib = koffi.load('RPCRT4.dll');
const RpcEpRegisterNoReplaceW = lib.func('__stdcall', 'RpcEpRegisterNoReplaceW', 'int32_t', ['void *', 'void *', 'void *', 'str16']);
// RpcEpRegisterNoReplaceW(IfSpec, BindingVector, UuidVector, Annotation)
// IfSpec : void* -> 'void *'
// BindingVector : RPC_BINDING_VECTOR* -> 'void *'
// UuidVector : UUID_VECTOR* optional -> 'void *'
// Annotation : LPWSTR optional -> 'str16'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("RPCRT4.dll", {
  RpcEpRegisterNoReplaceW: { parameters: ["pointer", "pointer", "pointer", "buffer"], result: "i32" },
});
// lib.symbols.RpcEpRegisterNoReplaceW(IfSpec, BindingVector, UuidVector, Annotation)
// IfSpec : void* -> "pointer"
// BindingVector : RPC_BINDING_VECTOR* -> "pointer"
// UuidVector : UUID_VECTOR* optional -> "pointer"
// Annotation : LPWSTR optional -> "buffer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t RpcEpRegisterNoReplaceW(
    void* IfSpec,
    void* BindingVector,
    void* UuidVector,
    const uint16_t* Annotation);
C, "RPCRT4.dll");
// $ffi->RpcEpRegisterNoReplaceW(IfSpec, BindingVector, UuidVector, Annotation);
// IfSpec : void*
// BindingVector : RPC_BINDING_VECTOR*
// UuidVector : UUID_VECTOR* optional
// Annotation : LPWSTR 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.UNICODE_OPTIONS);
    int RpcEpRegisterNoReplaceW(
        Pointer IfSpec,   // void*
        Pointer BindingVector,   // RPC_BINDING_VECTOR*
        Pointer UuidVector,   // UUID_VECTOR* optional
        WString Annotation   // LPWSTR optional
    );
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。
@[Link("rpcrt4")]
lib LibRPCRT4
  fun RpcEpRegisterNoReplaceW = RpcEpRegisterNoReplaceW(
    IfSpec : Void*,   # void*
    BindingVector : RPC_BINDING_VECTOR*,   # RPC_BINDING_VECTOR*
    UuidVector : UUID_VECTOR*,   # UUID_VECTOR* optional
    Annotation : UInt16*   # LPWSTR optional
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef RpcEpRegisterNoReplaceWNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Utf16>);
typedef RpcEpRegisterNoReplaceWDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Utf16>);
final RpcEpRegisterNoReplaceW = DynamicLibrary.open('RPCRT4.dll')
    .lookupFunction<RpcEpRegisterNoReplaceWNative, RpcEpRegisterNoReplaceWDart>('RpcEpRegisterNoReplaceW');
// IfSpec : void* -> Pointer<Void>
// BindingVector : RPC_BINDING_VECTOR* -> Pointer<Void>
// UuidVector : UUID_VECTOR* optional -> Pointer<Void>
// Annotation : LPWSTR optional -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function RpcEpRegisterNoReplaceW(
  IfSpec: Pointer;   // void*
  BindingVector: Pointer;   // RPC_BINDING_VECTOR*
  UuidVector: Pointer;   // UUID_VECTOR* optional
  Annotation: PWideChar   // LPWSTR optional
): Integer; stdcall;
  external 'RPCRT4.dll' name 'RpcEpRegisterNoReplaceW';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "RpcEpRegisterNoReplaceW"
  c_RpcEpRegisterNoReplaceW :: Ptr () -> Ptr () -> Ptr () -> CWString -> IO Int32
-- IfSpec : void* -> Ptr ()
-- BindingVector : RPC_BINDING_VECTOR* -> Ptr ()
-- UuidVector : UUID_VECTOR* optional -> Ptr ()
-- Annotation : LPWSTR optional -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let rpcepregisternoreplacew =
  foreign "RpcEpRegisterNoReplaceW"
    ((ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr uint16_t) @-> returning int32_t)
(* IfSpec : void* -> (ptr void) *)
(* BindingVector : RPC_BINDING_VECTOR* -> (ptr void) *)
(* UuidVector : UUID_VECTOR* optional -> (ptr void) *)
(* Annotation : LPWSTR optional -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library rpcrt4 (t "RPCRT4.dll"))
(cffi:use-foreign-library rpcrt4)

(cffi:defcfun ("RpcEpRegisterNoReplaceW" rpc-ep-register-no-replace-w :convention :stdcall) :int32
  (if-spec :pointer)   ; void*
  (binding-vector :pointer)   ; RPC_BINDING_VECTOR*
  (uuid-vector :pointer)   ; UUID_VECTOR* optional
  (annotation (:string :encoding :utf-16le)))   ; LPWSTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $RpcEpRegisterNoReplaceW = Win32::API::More->new('RPCRT4',
    'int RpcEpRegisterNoReplaceW(LPVOID IfSpec, LPVOID BindingVector, LPVOID UuidVector, LPCWSTR Annotation)');
# my $ret = $RpcEpRegisterNoReplaceW->Call($IfSpec, $BindingVector, $UuidVector, $Annotation);
# IfSpec : void* -> LPVOID
# BindingVector : RPC_BINDING_VECTOR* -> LPVOID
# UuidVector : UUID_VECTOR* optional -> LPVOID
# Annotation : LPWSTR optional -> LPCWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。

関連項目

文字セット違い
使用する型