ホーム › System.Rpc › RpcNsBindingExportW
RpcNsBindingExportW
関数ネームサービスにインターフェイスのバインディングをエクスポートする(Unicode版)。
シグネチャ
// RPCNS4.dll (Unicode / -W)
#include <windows.h>
RPC_STATUS RpcNsBindingExportW(
DWORD EntryNameSyntax,
LPWSTR EntryName, // optional
void* IfSpec, // optional
RPC_BINDING_VECTOR* BindingVec, // optional
UUID_VECTOR* ObjectUuidVec // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| EntryNameSyntax | DWORD | in | EntryNameの名前構文を指定するDWORD。0で既定構文を使用する。 |
| EntryName | LPWSTR | inoptional | バインディングをエクスポートするネームサービスのエントリ名(Unicode文字列)。 |
| IfSpec | void* | inoptional | エクスポートするインターフェイス仕様ハンドル。NULL可。 |
| BindingVec | RPC_BINDING_VECTOR* | inoptional | エクスポートするサーバーバインディングのベクターへのポインタ。NULL可。 |
| ObjectUuidVec | UUID_VECTOR* | inoptional | 関連付けるオブジェクトUUIDベクターへのポインタ。NULL可。 |
戻り値の型: RPC_STATUS
各言語での呼び出し定義
// RPCNS4.dll (Unicode / -W)
#include <windows.h>
RPC_STATUS RpcNsBindingExportW(
DWORD EntryNameSyntax,
LPWSTR EntryName, // optional
void* IfSpec, // optional
RPC_BINDING_VECTOR* BindingVec, // optional
UUID_VECTOR* ObjectUuidVec // optional
);[DllImport("RPCNS4.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int RpcNsBindingExportW(
uint EntryNameSyntax, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string EntryName, // LPWSTR optional
IntPtr IfSpec, // void* optional
IntPtr BindingVec, // RPC_BINDING_VECTOR* optional
IntPtr ObjectUuidVec // UUID_VECTOR* optional
);<DllImport("RPCNS4.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function RpcNsBindingExportW(
EntryNameSyntax As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> EntryName As String, ' LPWSTR optional
IfSpec As IntPtr, ' void* optional
BindingVec As IntPtr, ' RPC_BINDING_VECTOR* optional
ObjectUuidVec As IntPtr ' UUID_VECTOR* optional
) As Integer
End Function' EntryNameSyntax : DWORD
' EntryName : LPWSTR optional
' IfSpec : void* optional
' BindingVec : RPC_BINDING_VECTOR* optional
' ObjectUuidVec : UUID_VECTOR* optional
Declare PtrSafe Function RpcNsBindingExportW Lib "rpcns4" ( _
ByVal EntryNameSyntax As Long, _
ByVal EntryName As LongPtr, _
ByVal IfSpec As LongPtr, _
ByVal BindingVec As LongPtr, _
ByVal ObjectUuidVec 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
RpcNsBindingExportW = ctypes.windll.rpcns4.RpcNsBindingExportW
RpcNsBindingExportW.restype = ctypes.c_int
RpcNsBindingExportW.argtypes = [
wintypes.DWORD, # EntryNameSyntax : DWORD
wintypes.LPCWSTR, # EntryName : LPWSTR optional
ctypes.POINTER(None), # IfSpec : void* optional
ctypes.c_void_p, # BindingVec : RPC_BINDING_VECTOR* optional
ctypes.c_void_p, # ObjectUuidVec : UUID_VECTOR* optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('RPCNS4.dll')
RpcNsBindingExportW = Fiddle::Function.new(
lib['RpcNsBindingExportW'],
[
-Fiddle::TYPE_INT, # EntryNameSyntax : DWORD
Fiddle::TYPE_VOIDP, # EntryName : LPWSTR optional
Fiddle::TYPE_VOIDP, # IfSpec : void* optional
Fiddle::TYPE_VOIDP, # BindingVec : RPC_BINDING_VECTOR* optional
Fiddle::TYPE_VOIDP, # ObjectUuidVec : UUID_VECTOR* optional
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "rpcns4")]
extern "system" {
fn RpcNsBindingExportW(
EntryNameSyntax: u32, // DWORD
EntryName: *mut u16, // LPWSTR optional
IfSpec: *mut (), // void* optional
BindingVec: *mut RPC_BINDING_VECTOR, // RPC_BINDING_VECTOR* optional
ObjectUuidVec: *mut UUID_VECTOR // UUID_VECTOR* optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("RPCNS4.dll", CharSet = CharSet.Unicode)]
public static extern int RpcNsBindingExportW(uint EntryNameSyntax, [MarshalAs(UnmanagedType.LPWStr)] string EntryName, IntPtr IfSpec, IntPtr BindingVec, IntPtr ObjectUuidVec);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RPCNS4_RpcNsBindingExportW' -Namespace Win32 -PassThru
# $api::RpcNsBindingExportW(EntryNameSyntax, EntryName, IfSpec, BindingVec, ObjectUuidVec)#uselib "RPCNS4.dll"
#func global RpcNsBindingExportW "RpcNsBindingExportW" wptr, wptr, wptr, wptr, wptr
; RpcNsBindingExportW EntryNameSyntax, EntryName, IfSpec, varptr(BindingVec), varptr(ObjectUuidVec) ; 戻り値は stat
; EntryNameSyntax : DWORD -> "wptr"
; EntryName : LPWSTR optional -> "wptr"
; IfSpec : void* optional -> "wptr"
; BindingVec : RPC_BINDING_VECTOR* optional -> "wptr"
; ObjectUuidVec : UUID_VECTOR* optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "RPCNS4.dll" #cfunc global RpcNsBindingExportW "RpcNsBindingExportW" int, wstr, sptr, var, var ; res = RpcNsBindingExportW(EntryNameSyntax, EntryName, IfSpec, BindingVec, ObjectUuidVec) ; EntryNameSyntax : DWORD -> "int" ; EntryName : LPWSTR optional -> "wstr" ; IfSpec : void* optional -> "sptr" ; BindingVec : RPC_BINDING_VECTOR* optional -> "var" ; ObjectUuidVec : UUID_VECTOR* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "RPCNS4.dll" #cfunc global RpcNsBindingExportW "RpcNsBindingExportW" int, wstr, sptr, sptr, sptr ; res = RpcNsBindingExportW(EntryNameSyntax, EntryName, IfSpec, varptr(BindingVec), varptr(ObjectUuidVec)) ; EntryNameSyntax : DWORD -> "int" ; EntryName : LPWSTR optional -> "wstr" ; IfSpec : void* optional -> "sptr" ; BindingVec : RPC_BINDING_VECTOR* optional -> "sptr" ; ObjectUuidVec : UUID_VECTOR* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; RPC_STATUS RpcNsBindingExportW(DWORD EntryNameSyntax, LPWSTR EntryName, void* IfSpec, RPC_BINDING_VECTOR* BindingVec, UUID_VECTOR* ObjectUuidVec) #uselib "RPCNS4.dll" #cfunc global RpcNsBindingExportW "RpcNsBindingExportW" int, wstr, intptr, var, var ; res = RpcNsBindingExportW(EntryNameSyntax, EntryName, IfSpec, BindingVec, ObjectUuidVec) ; EntryNameSyntax : DWORD -> "int" ; EntryName : LPWSTR optional -> "wstr" ; IfSpec : void* optional -> "intptr" ; BindingVec : RPC_BINDING_VECTOR* optional -> "var" ; ObjectUuidVec : UUID_VECTOR* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; RPC_STATUS RpcNsBindingExportW(DWORD EntryNameSyntax, LPWSTR EntryName, void* IfSpec, RPC_BINDING_VECTOR* BindingVec, UUID_VECTOR* ObjectUuidVec) #uselib "RPCNS4.dll" #cfunc global RpcNsBindingExportW "RpcNsBindingExportW" int, wstr, intptr, intptr, intptr ; res = RpcNsBindingExportW(EntryNameSyntax, EntryName, IfSpec, varptr(BindingVec), varptr(ObjectUuidVec)) ; EntryNameSyntax : DWORD -> "int" ; EntryName : LPWSTR optional -> "wstr" ; IfSpec : void* optional -> "intptr" ; BindingVec : RPC_BINDING_VECTOR* optional -> "intptr" ; ObjectUuidVec : UUID_VECTOR* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
rpcns4 = windows.NewLazySystemDLL("RPCNS4.dll")
procRpcNsBindingExportW = rpcns4.NewProc("RpcNsBindingExportW")
)
// EntryNameSyntax (DWORD), EntryName (LPWSTR optional), IfSpec (void* optional), BindingVec (RPC_BINDING_VECTOR* optional), ObjectUuidVec (UUID_VECTOR* optional)
r1, _, err := procRpcNsBindingExportW.Call(
uintptr(EntryNameSyntax),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(EntryName))),
uintptr(IfSpec),
uintptr(BindingVec),
uintptr(ObjectUuidVec),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // RPC_STATUSfunction RpcNsBindingExportW(
EntryNameSyntax: DWORD; // DWORD
EntryName: PWideChar; // LPWSTR optional
IfSpec: Pointer; // void* optional
BindingVec: Pointer; // RPC_BINDING_VECTOR* optional
ObjectUuidVec: Pointer // UUID_VECTOR* optional
): Integer; stdcall;
external 'RPCNS4.dll' name 'RpcNsBindingExportW';result := DllCall("RPCNS4\RpcNsBindingExportW"
, "UInt", EntryNameSyntax ; DWORD
, "WStr", EntryName ; LPWSTR optional
, "Ptr", IfSpec ; void* optional
, "Ptr", BindingVec ; RPC_BINDING_VECTOR* optional
, "Ptr", ObjectUuidVec ; UUID_VECTOR* optional
, "Int") ; return: RPC_STATUS●RpcNsBindingExportW(EntryNameSyntax, EntryName, IfSpec, BindingVec, ObjectUuidVec) = DLL("RPCNS4.dll", "int RpcNsBindingExportW(dword, char*, void*, void*, void*)")
# 呼び出し: RpcNsBindingExportW(EntryNameSyntax, EntryName, IfSpec, BindingVec, ObjectUuidVec)
# EntryNameSyntax : DWORD -> "dword"
# EntryName : LPWSTR optional -> "char*"
# IfSpec : void* optional -> "void*"
# BindingVec : RPC_BINDING_VECTOR* optional -> "void*"
# ObjectUuidVec : UUID_VECTOR* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "rpcns4" fn RpcNsBindingExportW(
EntryNameSyntax: u32, // DWORD
EntryName: [*c]const u16, // LPWSTR optional
IfSpec: ?*anyopaque, // void* optional
BindingVec: [*c]RPC_BINDING_VECTOR, // RPC_BINDING_VECTOR* optional
ObjectUuidVec: [*c]UUID_VECTOR // UUID_VECTOR* optional
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc RpcNsBindingExportW(
EntryNameSyntax: uint32, # DWORD
EntryName: WideCString, # LPWSTR optional
IfSpec: pointer, # void* optional
BindingVec: ptr RPC_BINDING_VECTOR, # RPC_BINDING_VECTOR* optional
ObjectUuidVec: ptr UUID_VECTOR # UUID_VECTOR* optional
): int32 {.importc: "RpcNsBindingExportW", stdcall, dynlib: "RPCNS4.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "rpcns4");
extern(Windows)
int RpcNsBindingExportW(
uint EntryNameSyntax, // DWORD
const(wchar)* EntryName, // LPWSTR optional
void* IfSpec, // void* optional
RPC_BINDING_VECTOR* BindingVec, // RPC_BINDING_VECTOR* optional
UUID_VECTOR* ObjectUuidVec // UUID_VECTOR* optional
);ccall((:RpcNsBindingExportW, "RPCNS4.dll"), stdcall, Int32,
(UInt32, Cwstring, Ptr{Cvoid}, Ptr{RPC_BINDING_VECTOR}, Ptr{UUID_VECTOR}),
EntryNameSyntax, EntryName, IfSpec, BindingVec, ObjectUuidVec)
# EntryNameSyntax : DWORD -> UInt32
# EntryName : LPWSTR optional -> Cwstring
# IfSpec : void* optional -> Ptr{Cvoid}
# BindingVec : RPC_BINDING_VECTOR* optional -> Ptr{RPC_BINDING_VECTOR}
# ObjectUuidVec : UUID_VECTOR* optional -> Ptr{UUID_VECTOR}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int32_t RpcNsBindingExportW(
uint32_t EntryNameSyntax,
const uint16_t* EntryName,
void* IfSpec,
void* BindingVec,
void* ObjectUuidVec);
]]
local rpcns4 = ffi.load("rpcns4")
-- rpcns4.RpcNsBindingExportW(EntryNameSyntax, EntryName, IfSpec, BindingVec, ObjectUuidVec)
-- EntryNameSyntax : DWORD
-- EntryName : LPWSTR optional
-- IfSpec : void* optional
-- BindingVec : RPC_BINDING_VECTOR* optional
-- ObjectUuidVec : UUID_VECTOR* 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('RPCNS4.dll');
const RpcNsBindingExportW = lib.func('__stdcall', 'RpcNsBindingExportW', 'int32_t', ['uint32_t', 'str16', 'void *', 'void *', 'void *']);
// RpcNsBindingExportW(EntryNameSyntax, EntryName, IfSpec, BindingVec, ObjectUuidVec)
// EntryNameSyntax : DWORD -> 'uint32_t'
// EntryName : LPWSTR optional -> 'str16'
// IfSpec : void* optional -> 'void *'
// BindingVec : RPC_BINDING_VECTOR* optional -> 'void *'
// ObjectUuidVec : UUID_VECTOR* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("RPCNS4.dll", {
RpcNsBindingExportW: { parameters: ["u32", "buffer", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.RpcNsBindingExportW(EntryNameSyntax, EntryName, IfSpec, BindingVec, ObjectUuidVec)
// EntryNameSyntax : DWORD -> "u32"
// EntryName : LPWSTR optional -> "buffer"
// IfSpec : void* optional -> "pointer"
// BindingVec : RPC_BINDING_VECTOR* optional -> "pointer"
// ObjectUuidVec : UUID_VECTOR* optional -> "pointer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t RpcNsBindingExportW(
uint32_t EntryNameSyntax,
const uint16_t* EntryName,
void* IfSpec,
void* BindingVec,
void* ObjectUuidVec);
C, "RPCNS4.dll");
// $ffi->RpcNsBindingExportW(EntryNameSyntax, EntryName, IfSpec, BindingVec, ObjectUuidVec);
// EntryNameSyntax : DWORD
// EntryName : LPWSTR optional
// IfSpec : void* optional
// BindingVec : RPC_BINDING_VECTOR* optional
// ObjectUuidVec : UUID_VECTOR* 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 Rpcns4 extends StdCallLibrary {
Rpcns4 INSTANCE = Native.load("rpcns4", Rpcns4.class, W32APIOptions.UNICODE_OPTIONS);
int RpcNsBindingExportW(
int EntryNameSyntax, // DWORD
WString EntryName, // LPWSTR optional
Pointer IfSpec, // void* optional
Pointer BindingVec, // RPC_BINDING_VECTOR* optional
Pointer ObjectUuidVec // UUID_VECTOR* optional
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("rpcns4")]
lib LibRPCNS4
fun RpcNsBindingExportW = RpcNsBindingExportW(
EntryNameSyntax : UInt32, # DWORD
EntryName : UInt16*, # LPWSTR optional
IfSpec : Void*, # void* optional
BindingVec : RPC_BINDING_VECTOR*, # RPC_BINDING_VECTOR* optional
ObjectUuidVec : UUID_VECTOR* # UUID_VECTOR* optional
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef RpcNsBindingExportWNative = Int32 Function(Uint32, Pointer<Utf16>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
typedef RpcNsBindingExportWDart = int Function(int, Pointer<Utf16>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
final RpcNsBindingExportW = DynamicLibrary.open('RPCNS4.dll')
.lookupFunction<RpcNsBindingExportWNative, RpcNsBindingExportWDart>('RpcNsBindingExportW');
// EntryNameSyntax : DWORD -> Uint32
// EntryName : LPWSTR optional -> Pointer<Utf16>
// IfSpec : void* optional -> Pointer<Void>
// BindingVec : RPC_BINDING_VECTOR* optional -> Pointer<Void>
// ObjectUuidVec : UUID_VECTOR* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function RpcNsBindingExportW(
EntryNameSyntax: DWORD; // DWORD
EntryName: PWideChar; // LPWSTR optional
IfSpec: Pointer; // void* optional
BindingVec: Pointer; // RPC_BINDING_VECTOR* optional
ObjectUuidVec: Pointer // UUID_VECTOR* optional
): Integer; stdcall;
external 'RPCNS4.dll' name 'RpcNsBindingExportW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RpcNsBindingExportW"
c_RpcNsBindingExportW :: Word32 -> CWString -> Ptr () -> Ptr () -> Ptr () -> IO Int32
-- EntryNameSyntax : DWORD -> Word32
-- EntryName : LPWSTR optional -> CWString
-- IfSpec : void* optional -> Ptr ()
-- BindingVec : RPC_BINDING_VECTOR* optional -> Ptr ()
-- ObjectUuidVec : UUID_VECTOR* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let rpcnsbindingexportw =
foreign "RpcNsBindingExportW"
(uint32_t @-> (ptr uint16_t) @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* EntryNameSyntax : DWORD -> uint32_t *)
(* EntryName : LPWSTR optional -> (ptr uint16_t) *)
(* IfSpec : void* optional -> (ptr void) *)
(* BindingVec : RPC_BINDING_VECTOR* optional -> (ptr void) *)
(* ObjectUuidVec : UUID_VECTOR* optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library rpcns4 (t "RPCNS4.dll"))
(cffi:use-foreign-library rpcns4)
(cffi:defcfun ("RpcNsBindingExportW" rpc-ns-binding-export-w :convention :stdcall) :int32
(entry-name-syntax :uint32) ; DWORD
(entry-name (:string :encoding :utf-16le)) ; LPWSTR optional
(if-spec :pointer) ; void* optional
(binding-vec :pointer) ; RPC_BINDING_VECTOR* optional
(object-uuid-vec :pointer)) ; UUID_VECTOR* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RpcNsBindingExportW = Win32::API::More->new('RPCNS4',
'int RpcNsBindingExportW(DWORD EntryNameSyntax, LPCWSTR EntryName, LPVOID IfSpec, LPVOID BindingVec, LPVOID ObjectUuidVec)');
# my $ret = $RpcNsBindingExportW->Call($EntryNameSyntax, $EntryName, $IfSpec, $BindingVec, $ObjectUuidVec);
# EntryNameSyntax : DWORD -> DWORD
# EntryName : LPWSTR optional -> LPCWSTR
# IfSpec : void* optional -> LPVOID
# BindingVec : RPC_BINDING_VECTOR* optional -> LPVOID
# ObjectUuidVec : UUID_VECTOR* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f RpcNsBindingExportA (ANSI版) — ネームサービスにインターフェイスのバインディングをエクスポートする(ANSI版)。