ホーム › System.Rpc › RpcNsBindingLookupBeginA
RpcNsBindingLookupBeginA
関数ネームサービスからの互換バインディング検索を開始する(ANSI版)。
シグネチャ
// RPCNS4.dll (ANSI / -A)
#include <windows.h>
RPC_STATUS RpcNsBindingLookupBeginA(
DWORD EntryNameSyntax,
LPSTR EntryName, // optional
void* IfSpec, // optional
GUID* ObjUuid, // optional
DWORD BindingMaxCount,
void** LookupContext
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| EntryNameSyntax | DWORD | in | EntryNameの名前構文を指定するDWORD。0で既定構文を使用する。 |
| EntryName | LPSTR | inoptional | 検索を開始するネームサービスのエントリ名(ANSI文字列)。NULL可。 |
| IfSpec | void* | inoptional | 検索対象のインターフェイス仕様ハンドル。NULL可。 |
| ObjUuid | GUID* | inoptional | 検索条件とするオブジェクトUUIDへのポインタ。NULL可で任意のオブジェクトを対象とする。 |
| BindingMaxCount | DWORD | in | 1回のLookupNextで返すバインディングの最大数。0で既定値を使用する。 |
| LookupContext | void** | out | 後続のLookupNext/Doneで使う検索コンテキストを受け取るポインタのアドレス。 |
戻り値の型: RPC_STATUS
各言語での呼び出し定義
// RPCNS4.dll (ANSI / -A)
#include <windows.h>
RPC_STATUS RpcNsBindingLookupBeginA(
DWORD EntryNameSyntax,
LPSTR EntryName, // optional
void* IfSpec, // optional
GUID* ObjUuid, // optional
DWORD BindingMaxCount,
void** LookupContext
);[DllImport("RPCNS4.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int RpcNsBindingLookupBeginA(
uint EntryNameSyntax, // DWORD
[MarshalAs(UnmanagedType.LPStr)] string EntryName, // LPSTR optional
IntPtr IfSpec, // void* optional
IntPtr ObjUuid, // GUID* optional
uint BindingMaxCount, // DWORD
IntPtr LookupContext // void** out
);<DllImport("RPCNS4.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function RpcNsBindingLookupBeginA(
EntryNameSyntax As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPStr)> EntryName As String, ' LPSTR optional
IfSpec As IntPtr, ' void* optional
ObjUuid As IntPtr, ' GUID* optional
BindingMaxCount As UInteger, ' DWORD
LookupContext As IntPtr ' void** out
) As Integer
End Function' EntryNameSyntax : DWORD
' EntryName : LPSTR optional
' IfSpec : void* optional
' ObjUuid : GUID* optional
' BindingMaxCount : DWORD
' LookupContext : void** out
Declare PtrSafe Function RpcNsBindingLookupBeginA Lib "rpcns4" ( _
ByVal EntryNameSyntax As Long, _
ByVal EntryName As String, _
ByVal IfSpec As LongPtr, _
ByVal ObjUuid As LongPtr, _
ByVal BindingMaxCount As Long, _
ByVal LookupContext As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RpcNsBindingLookupBeginA = ctypes.windll.rpcns4.RpcNsBindingLookupBeginA
RpcNsBindingLookupBeginA.restype = ctypes.c_int
RpcNsBindingLookupBeginA.argtypes = [
wintypes.DWORD, # EntryNameSyntax : DWORD
wintypes.LPCSTR, # EntryName : LPSTR optional
ctypes.POINTER(None), # IfSpec : void* optional
ctypes.c_void_p, # ObjUuid : GUID* optional
wintypes.DWORD, # BindingMaxCount : DWORD
ctypes.c_void_p, # LookupContext : void** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('RPCNS4.dll')
RpcNsBindingLookupBeginA = Fiddle::Function.new(
lib['RpcNsBindingLookupBeginA'],
[
-Fiddle::TYPE_INT, # EntryNameSyntax : DWORD
Fiddle::TYPE_VOIDP, # EntryName : LPSTR optional
Fiddle::TYPE_VOIDP, # IfSpec : void* optional
Fiddle::TYPE_VOIDP, # ObjUuid : GUID* optional
-Fiddle::TYPE_INT, # BindingMaxCount : DWORD
Fiddle::TYPE_VOIDP, # LookupContext : void** out
],
Fiddle::TYPE_INT)#[link(name = "rpcns4")]
extern "system" {
fn RpcNsBindingLookupBeginA(
EntryNameSyntax: u32, // DWORD
EntryName: *mut u8, // LPSTR optional
IfSpec: *mut (), // void* optional
ObjUuid: *mut GUID, // GUID* optional
BindingMaxCount: u32, // DWORD
LookupContext: *mut *mut () // void** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("RPCNS4.dll", CharSet = CharSet.Ansi)]
public static extern int RpcNsBindingLookupBeginA(uint EntryNameSyntax, [MarshalAs(UnmanagedType.LPStr)] string EntryName, IntPtr IfSpec, IntPtr ObjUuid, uint BindingMaxCount, IntPtr LookupContext);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RPCNS4_RpcNsBindingLookupBeginA' -Namespace Win32 -PassThru
# $api::RpcNsBindingLookupBeginA(EntryNameSyntax, EntryName, IfSpec, ObjUuid, BindingMaxCount, LookupContext)#uselib "RPCNS4.dll"
#func global RpcNsBindingLookupBeginA "RpcNsBindingLookupBeginA" sptr, sptr, sptr, sptr, sptr, sptr
; RpcNsBindingLookupBeginA EntryNameSyntax, EntryName, IfSpec, varptr(ObjUuid), BindingMaxCount, LookupContext ; 戻り値は stat
; EntryNameSyntax : DWORD -> "sptr"
; EntryName : LPSTR optional -> "sptr"
; IfSpec : void* optional -> "sptr"
; ObjUuid : GUID* optional -> "sptr"
; BindingMaxCount : DWORD -> "sptr"
; LookupContext : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "RPCNS4.dll" #cfunc global RpcNsBindingLookupBeginA "RpcNsBindingLookupBeginA" int, str, sptr, var, int, sptr ; res = RpcNsBindingLookupBeginA(EntryNameSyntax, EntryName, IfSpec, ObjUuid, BindingMaxCount, LookupContext) ; EntryNameSyntax : DWORD -> "int" ; EntryName : LPSTR optional -> "str" ; IfSpec : void* optional -> "sptr" ; ObjUuid : GUID* optional -> "var" ; BindingMaxCount : DWORD -> "int" ; LookupContext : void** out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "RPCNS4.dll" #cfunc global RpcNsBindingLookupBeginA "RpcNsBindingLookupBeginA" int, str, sptr, sptr, int, sptr ; res = RpcNsBindingLookupBeginA(EntryNameSyntax, EntryName, IfSpec, varptr(ObjUuid), BindingMaxCount, LookupContext) ; EntryNameSyntax : DWORD -> "int" ; EntryName : LPSTR optional -> "str" ; IfSpec : void* optional -> "sptr" ; ObjUuid : GUID* optional -> "sptr" ; BindingMaxCount : DWORD -> "int" ; LookupContext : void** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; RPC_STATUS RpcNsBindingLookupBeginA(DWORD EntryNameSyntax, LPSTR EntryName, void* IfSpec, GUID* ObjUuid, DWORD BindingMaxCount, void** LookupContext) #uselib "RPCNS4.dll" #cfunc global RpcNsBindingLookupBeginA "RpcNsBindingLookupBeginA" int, str, intptr, var, int, intptr ; res = RpcNsBindingLookupBeginA(EntryNameSyntax, EntryName, IfSpec, ObjUuid, BindingMaxCount, LookupContext) ; EntryNameSyntax : DWORD -> "int" ; EntryName : LPSTR optional -> "str" ; IfSpec : void* optional -> "intptr" ; ObjUuid : GUID* optional -> "var" ; BindingMaxCount : DWORD -> "int" ; LookupContext : void** out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; RPC_STATUS RpcNsBindingLookupBeginA(DWORD EntryNameSyntax, LPSTR EntryName, void* IfSpec, GUID* ObjUuid, DWORD BindingMaxCount, void** LookupContext) #uselib "RPCNS4.dll" #cfunc global RpcNsBindingLookupBeginA "RpcNsBindingLookupBeginA" int, str, intptr, intptr, int, intptr ; res = RpcNsBindingLookupBeginA(EntryNameSyntax, EntryName, IfSpec, varptr(ObjUuid), BindingMaxCount, LookupContext) ; EntryNameSyntax : DWORD -> "int" ; EntryName : LPSTR optional -> "str" ; IfSpec : void* optional -> "intptr" ; ObjUuid : GUID* optional -> "intptr" ; BindingMaxCount : DWORD -> "int" ; LookupContext : void** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
rpcns4 = windows.NewLazySystemDLL("RPCNS4.dll")
procRpcNsBindingLookupBeginA = rpcns4.NewProc("RpcNsBindingLookupBeginA")
)
// EntryNameSyntax (DWORD), EntryName (LPSTR optional), IfSpec (void* optional), ObjUuid (GUID* optional), BindingMaxCount (DWORD), LookupContext (void** out)
r1, _, err := procRpcNsBindingLookupBeginA.Call(
uintptr(EntryNameSyntax),
uintptr(unsafe.Pointer(windows.BytePtrFromString(EntryName))),
uintptr(IfSpec),
uintptr(ObjUuid),
uintptr(BindingMaxCount),
uintptr(LookupContext),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // RPC_STATUSfunction RpcNsBindingLookupBeginA(
EntryNameSyntax: DWORD; // DWORD
EntryName: PAnsiChar; // LPSTR optional
IfSpec: Pointer; // void* optional
ObjUuid: PGUID; // GUID* optional
BindingMaxCount: DWORD; // DWORD
LookupContext: Pointer // void** out
): Integer; stdcall;
external 'RPCNS4.dll' name 'RpcNsBindingLookupBeginA';result := DllCall("RPCNS4\RpcNsBindingLookupBeginA"
, "UInt", EntryNameSyntax ; DWORD
, "AStr", EntryName ; LPSTR optional
, "Ptr", IfSpec ; void* optional
, "Ptr", ObjUuid ; GUID* optional
, "UInt", BindingMaxCount ; DWORD
, "Ptr", LookupContext ; void** out
, "Int") ; return: RPC_STATUS●RpcNsBindingLookupBeginA(EntryNameSyntax, EntryName, IfSpec, ObjUuid, BindingMaxCount, LookupContext) = DLL("RPCNS4.dll", "int RpcNsBindingLookupBeginA(dword, char*, void*, void*, dword, void*)")
# 呼び出し: RpcNsBindingLookupBeginA(EntryNameSyntax, EntryName, IfSpec, ObjUuid, BindingMaxCount, LookupContext)
# EntryNameSyntax : DWORD -> "dword"
# EntryName : LPSTR optional -> "char*"
# IfSpec : void* optional -> "void*"
# ObjUuid : GUID* optional -> "void*"
# BindingMaxCount : DWORD -> "dword"
# LookupContext : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "rpcns4" fn RpcNsBindingLookupBeginA(
EntryNameSyntax: u32, // DWORD
EntryName: [*c]const u8, // LPSTR optional
IfSpec: ?*anyopaque, // void* optional
ObjUuid: [*c]GUID, // GUID* optional
BindingMaxCount: u32, // DWORD
LookupContext: ?*anyopaque // void** out
) callconv(std.os.windows.WINAPI) i32;proc RpcNsBindingLookupBeginA(
EntryNameSyntax: uint32, # DWORD
EntryName: cstring, # LPSTR optional
IfSpec: pointer, # void* optional
ObjUuid: ptr GUID, # GUID* optional
BindingMaxCount: uint32, # DWORD
LookupContext: pointer # void** out
): int32 {.importc: "RpcNsBindingLookupBeginA", stdcall, dynlib: "RPCNS4.dll".}pragma(lib, "rpcns4");
extern(Windows)
int RpcNsBindingLookupBeginA(
uint EntryNameSyntax, // DWORD
const(char)* EntryName, // LPSTR optional
void* IfSpec, // void* optional
GUID* ObjUuid, // GUID* optional
uint BindingMaxCount, // DWORD
void** LookupContext // void** out
);ccall((:RpcNsBindingLookupBeginA, "RPCNS4.dll"), stdcall, Int32,
(UInt32, Cstring, Ptr{Cvoid}, Ptr{GUID}, UInt32, Ptr{Cvoid}),
EntryNameSyntax, EntryName, IfSpec, ObjUuid, BindingMaxCount, LookupContext)
# EntryNameSyntax : DWORD -> UInt32
# EntryName : LPSTR optional -> Cstring
# IfSpec : void* optional -> Ptr{Cvoid}
# ObjUuid : GUID* optional -> Ptr{GUID}
# BindingMaxCount : DWORD -> UInt32
# LookupContext : void** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t RpcNsBindingLookupBeginA(
uint32_t EntryNameSyntax,
const char* EntryName,
void* IfSpec,
void* ObjUuid,
uint32_t BindingMaxCount,
void** LookupContext);
]]
local rpcns4 = ffi.load("rpcns4")
-- rpcns4.RpcNsBindingLookupBeginA(EntryNameSyntax, EntryName, IfSpec, ObjUuid, BindingMaxCount, LookupContext)
-- EntryNameSyntax : DWORD
-- EntryName : LPSTR optional
-- IfSpec : void* optional
-- ObjUuid : GUID* optional
-- BindingMaxCount : DWORD
-- LookupContext : void** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('RPCNS4.dll');
const RpcNsBindingLookupBeginA = lib.func('__stdcall', 'RpcNsBindingLookupBeginA', 'int32_t', ['uint32_t', 'str', 'void *', 'void *', 'uint32_t', 'void *']);
// RpcNsBindingLookupBeginA(EntryNameSyntax, EntryName, IfSpec, ObjUuid, BindingMaxCount, LookupContext)
// EntryNameSyntax : DWORD -> 'uint32_t'
// EntryName : LPSTR optional -> 'str'
// IfSpec : void* optional -> 'void *'
// ObjUuid : GUID* optional -> 'void *'
// BindingMaxCount : DWORD -> 'uint32_t'
// LookupContext : void** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("RPCNS4.dll", {
RpcNsBindingLookupBeginA: { parameters: ["u32", "buffer", "pointer", "pointer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.RpcNsBindingLookupBeginA(EntryNameSyntax, EntryName, IfSpec, ObjUuid, BindingMaxCount, LookupContext)
// EntryNameSyntax : DWORD -> "u32"
// EntryName : LPSTR optional -> "buffer"
// IfSpec : void* optional -> "pointer"
// ObjUuid : GUID* optional -> "pointer"
// BindingMaxCount : DWORD -> "u32"
// LookupContext : void** out -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t RpcNsBindingLookupBeginA(
uint32_t EntryNameSyntax,
const char* EntryName,
void* IfSpec,
void* ObjUuid,
uint32_t BindingMaxCount,
void** LookupContext);
C, "RPCNS4.dll");
// $ffi->RpcNsBindingLookupBeginA(EntryNameSyntax, EntryName, IfSpec, ObjUuid, BindingMaxCount, LookupContext);
// EntryNameSyntax : DWORD
// EntryName : LPSTR optional
// IfSpec : void* optional
// ObjUuid : GUID* optional
// BindingMaxCount : DWORD
// LookupContext : void** out
// 構造体/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.ASCII_OPTIONS);
int RpcNsBindingLookupBeginA(
int EntryNameSyntax, // DWORD
String EntryName, // LPSTR optional
Pointer IfSpec, // void* optional
Pointer ObjUuid, // GUID* optional
int BindingMaxCount, // DWORD
Pointer LookupContext // void** out
);
}@[Link("rpcns4")]
lib LibRPCNS4
fun RpcNsBindingLookupBeginA = RpcNsBindingLookupBeginA(
EntryNameSyntax : UInt32, # DWORD
EntryName : UInt8*, # LPSTR optional
IfSpec : Void*, # void* optional
ObjUuid : GUID*, # GUID* optional
BindingMaxCount : UInt32, # DWORD
LookupContext : Void** # void** out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef RpcNsBindingLookupBeginANative = Int32 Function(Uint32, Pointer<Utf8>, Pointer<Void>, Pointer<Void>, Uint32, Pointer<Void>);
typedef RpcNsBindingLookupBeginADart = int Function(int, Pointer<Utf8>, Pointer<Void>, Pointer<Void>, int, Pointer<Void>);
final RpcNsBindingLookupBeginA = DynamicLibrary.open('RPCNS4.dll')
.lookupFunction<RpcNsBindingLookupBeginANative, RpcNsBindingLookupBeginADart>('RpcNsBindingLookupBeginA');
// EntryNameSyntax : DWORD -> Uint32
// EntryName : LPSTR optional -> Pointer<Utf8>
// IfSpec : void* optional -> Pointer<Void>
// ObjUuid : GUID* optional -> Pointer<Void>
// BindingMaxCount : DWORD -> Uint32
// LookupContext : void** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function RpcNsBindingLookupBeginA(
EntryNameSyntax: DWORD; // DWORD
EntryName: PAnsiChar; // LPSTR optional
IfSpec: Pointer; // void* optional
ObjUuid: PGUID; // GUID* optional
BindingMaxCount: DWORD; // DWORD
LookupContext: Pointer // void** out
): Integer; stdcall;
external 'RPCNS4.dll' name 'RpcNsBindingLookupBeginA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RpcNsBindingLookupBeginA"
c_RpcNsBindingLookupBeginA :: Word32 -> CString -> Ptr () -> Ptr () -> Word32 -> Ptr () -> IO Int32
-- EntryNameSyntax : DWORD -> Word32
-- EntryName : LPSTR optional -> CString
-- IfSpec : void* optional -> Ptr ()
-- ObjUuid : GUID* optional -> Ptr ()
-- BindingMaxCount : DWORD -> Word32
-- LookupContext : void** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let rpcnsbindinglookupbegina =
foreign "RpcNsBindingLookupBeginA"
(uint32_t @-> string @-> (ptr void) @-> (ptr void) @-> uint32_t @-> (ptr void) @-> returning int32_t)
(* EntryNameSyntax : DWORD -> uint32_t *)
(* EntryName : LPSTR optional -> string *)
(* IfSpec : void* optional -> (ptr void) *)
(* ObjUuid : GUID* optional -> (ptr void) *)
(* BindingMaxCount : DWORD -> uint32_t *)
(* LookupContext : void** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library rpcns4 (t "RPCNS4.dll"))
(cffi:use-foreign-library rpcns4)
(cffi:defcfun ("RpcNsBindingLookupBeginA" rpc-ns-binding-lookup-begin-a :convention :stdcall) :int32
(entry-name-syntax :uint32) ; DWORD
(entry-name :string) ; LPSTR optional
(if-spec :pointer) ; void* optional
(obj-uuid :pointer) ; GUID* optional
(binding-max-count :uint32) ; DWORD
(lookup-context :pointer)) ; void** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RpcNsBindingLookupBeginA = Win32::API::More->new('RPCNS4',
'int RpcNsBindingLookupBeginA(DWORD EntryNameSyntax, LPCSTR EntryName, LPVOID IfSpec, LPVOID ObjUuid, DWORD BindingMaxCount, LPVOID LookupContext)');
# my $ret = $RpcNsBindingLookupBeginA->Call($EntryNameSyntax, $EntryName, $IfSpec, $ObjUuid, $BindingMaxCount, $LookupContext);
# EntryNameSyntax : DWORD -> DWORD
# EntryName : LPSTR optional -> LPCSTR
# IfSpec : void* optional -> LPVOID
# ObjUuid : GUID* optional -> LPVOID
# BindingMaxCount : DWORD -> DWORD
# LookupContext : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f RpcNsBindingLookupBeginW (Unicode版) — ネームサービスからの互換バインディング検索を開始する(Unicode版)。
使用する型