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

RpcNsBindingLookupBeginW

関数
ネームサービスからの互換バインディング検索を開始する(Unicode版)。
DLLRPCNS4.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

RPC_STATUS RpcNsBindingLookupBeginW(
    DWORD EntryNameSyntax,
    LPWSTR EntryName,   // optional
    void* IfSpec,   // optional
    GUID* ObjUuid,   // optional
    DWORD BindingMaxCount,
    void** LookupContext
);

パラメーター

名前方向説明
EntryNameSyntaxDWORDin

EntryName パラメーターの構文。

レジストリ値エントリ HKEY_LOCAL_MACHINE\Software\Microsoft\Rpc\NameService\DefaultSyntax で指定された構文を使用するには、RPC_C_NS_SYNTAX_DEFAULT を指定します。

EntryNameLPWSTRinoptional

互換性のあるバインディングの検索を開始するエントリ名へのポインター。

レジストリ値エントリ HKEY_LOCAL_MACHINE\Software\Microsoft\Rpc\NameService\DefaultEntry で指定されたエントリ名を使用するには、null ポインターまたは空の文字列を指定します。この場合、EntryNameSyntax パラメーターは無視され、ランタイム ライブラリは既定の構文を使用します。

IfSpecvoid*inoptional検索対象のインターフェイスを示す、スタブが生成した構造体。インターフェイス仕様がエクスポートされていない場合、または呼び出し元にとって重要でない場合は、このパラメーターに null 値を指定します。この場合、返されるバインディングは、互換性がありサポートされているプロトコル シーケンスであること、および指定されたオブジェクト UUID を含むことのみが保証されます。目的のインターフェイスは、接続先のサーバーでサポートされていない可能性があります。
ObjUuidGUID*inoptional

省略可能なオブジェクト UUID へのポインター。

非ゼロの UUID の場合、サーバーが指定されたオブジェクト UUID をエクスポートしているときにのみ、そのエントリから互換性のあるバインディング ハンドルが返されます。

このパラメーターに null ポインター値または nil UUID を指定した場合、返されるバインディング ハンドルには、互換性のあるサーバーがエクスポートしたオブジェクト UUID のいずれかが含まれます。サーバーがオブジェクト UUID を一つもエクスポートしていない場合、返される互換性のあるバインディング ハンドルには nil のオブジェクト UUID が含まれます。

BindingMaxCountDWORDin

RpcNsBindingLookupNext 関数が BindingVec パラメーターで返すバインディングの最大数。

既定の数である RPC_C_BINDING_MAX_COUNT_DEFAULT を使用するには、値 0 を指定します。

LookupContextvoid**outRpcNsBindingLookupNext 関数および RpcNsBindingLookupDone 関数で使用するネーム サービス ハンドルへのポインターを返します。

戻り値の型: RPC_STATUS

公式ドキュメント

RpcNsBindingLookupBegin 関数は、インターフェイスとオブジェクトに対する検索コンテキストを作成します。(Unicode)

戻り値

意味
RPC_S_OK
呼び出しは成功しました。
RPC_S_INVALID_NAME_SYNTAX
名前の構文が無効です。
RPC_S_UNSUPPORTED_NAME_SYNTAX
名前の構文がサポートされていません。
RPC_S_INCOMPLETE_NAME
名前が不完全です。
RPC_S_ENTRY_NOT_FOUND
ネーム サービスのエントリが見つかりませんでした。
RPC_S_NAME_SERVICE_UNAVAILABLE
ネーム サービスを利用できません。
RPC_S_INVALID_OBJECT
オブジェクトが無効です。
有効なエラー コードの一覧については、 RPC Return Values を参照してください。

解説(Remarks)

RpcNsBindingLookupBegin 関数は、指定されたインターフェイスとオブジェクトを提供するサーバーへの、クライアントと互換性のあるバインディング ハンドルを検索するための検索コンテキストを作成します。

RpcNsBindingLookupNext を呼び出す前に、クライアント アプリケーションはまず RpcNsBindingLookupBegin を呼び出して検索コンテキストを作成する必要があります。この関数のパラメーターは、 RpcNsBindingLookupNext 関数の動作を制御します。

Windows 2000 以降、RPC 環境はネーム サービス データベースとして Active Directory を使用し、ランタイム環境は次の順序で検索を実行します。

バインディング ハンドルの検索が完了したら、クライアント アプリケーションは RpcNsBindingLookupDone 関数を呼び出して検索コンテキストを削除します。
メモ

rpcnsi.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして RpcNsBindingLookupBegin を定義しています。エンコード中立のエイリアスの使用と、エンコード中立でないコードを混在させると、不一致が発生し、コンパイル エラーまたは実行時エラーの原因となる可能性があります。詳細については、Conventions for Function Prototypes を参照してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

RPC_STATUS RpcNsBindingLookupBeginW(
    DWORD EntryNameSyntax,
    LPWSTR EntryName,   // optional
    void* IfSpec,   // optional
    GUID* ObjUuid,   // optional
    DWORD BindingMaxCount,
    void** LookupContext
);
[DllImport("RPCNS4.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int RpcNsBindingLookupBeginW(
    uint EntryNameSyntax,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] string EntryName,   // LPWSTR optional
    IntPtr IfSpec,   // void* optional
    IntPtr ObjUuid,   // GUID* optional
    uint BindingMaxCount,   // DWORD
    IntPtr LookupContext   // void** out
);
<DllImport("RPCNS4.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function RpcNsBindingLookupBeginW(
    EntryNameSyntax As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> EntryName As String,   ' LPWSTR 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 : LPWSTR optional
' IfSpec : void* optional
' ObjUuid : GUID* optional
' BindingMaxCount : DWORD
' LookupContext : void** out
Declare PtrSafe Function RpcNsBindingLookupBeginW Lib "rpcns4" ( _
    ByVal EntryNameSyntax As Long, _
    ByVal EntryName As LongPtr, _
    ByVal IfSpec As LongPtr, _
    ByVal ObjUuid As LongPtr, _
    ByVal BindingMaxCount As Long, _
    ByVal LookupContext 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

RpcNsBindingLookupBeginW = ctypes.windll.rpcns4.RpcNsBindingLookupBeginW
RpcNsBindingLookupBeginW.restype = ctypes.c_int
RpcNsBindingLookupBeginW.argtypes = [
    wintypes.DWORD,  # EntryNameSyntax : DWORD
    wintypes.LPCWSTR,  # EntryName : LPWSTR 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')
RpcNsBindingLookupBeginW = Fiddle::Function.new(
  lib['RpcNsBindingLookupBeginW'],
  [
    -Fiddle::TYPE_INT,  # EntryNameSyntax : DWORD
    Fiddle::TYPE_VOIDP,  # EntryName : LPWSTR 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)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "rpcns4")]
extern "system" {
    fn RpcNsBindingLookupBeginW(
        EntryNameSyntax: u32,  // DWORD
        EntryName: *mut u16,  // LPWSTR 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.Unicode)]
public static extern int RpcNsBindingLookupBeginW(uint EntryNameSyntax, [MarshalAs(UnmanagedType.LPWStr)] string EntryName, IntPtr IfSpec, IntPtr ObjUuid, uint BindingMaxCount, IntPtr LookupContext);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RPCNS4_RpcNsBindingLookupBeginW' -Namespace Win32 -PassThru
# $api::RpcNsBindingLookupBeginW(EntryNameSyntax, EntryName, IfSpec, ObjUuid, BindingMaxCount, LookupContext)
#uselib "RPCNS4.dll"
#func global RpcNsBindingLookupBeginW "RpcNsBindingLookupBeginW" wptr, wptr, wptr, wptr, wptr, wptr
; RpcNsBindingLookupBeginW EntryNameSyntax, EntryName, IfSpec, varptr(ObjUuid), BindingMaxCount, LookupContext   ; 戻り値は stat
; EntryNameSyntax : DWORD -> "wptr"
; EntryName : LPWSTR optional -> "wptr"
; IfSpec : void* optional -> "wptr"
; ObjUuid : GUID* optional -> "wptr"
; BindingMaxCount : DWORD -> "wptr"
; LookupContext : void** out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "RPCNS4.dll"
#cfunc global RpcNsBindingLookupBeginW "RpcNsBindingLookupBeginW" int, wstr, sptr, var, int, sptr
; res = RpcNsBindingLookupBeginW(EntryNameSyntax, EntryName, IfSpec, ObjUuid, BindingMaxCount, LookupContext)
; EntryNameSyntax : DWORD -> "int"
; EntryName : LPWSTR optional -> "wstr"
; IfSpec : void* optional -> "sptr"
; ObjUuid : GUID* optional -> "var"
; BindingMaxCount : DWORD -> "int"
; LookupContext : void** out -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; RPC_STATUS RpcNsBindingLookupBeginW(DWORD EntryNameSyntax, LPWSTR EntryName, void* IfSpec, GUID* ObjUuid, DWORD BindingMaxCount, void** LookupContext)
#uselib "RPCNS4.dll"
#cfunc global RpcNsBindingLookupBeginW "RpcNsBindingLookupBeginW" int, wstr, intptr, var, int, intptr
; res = RpcNsBindingLookupBeginW(EntryNameSyntax, EntryName, IfSpec, ObjUuid, BindingMaxCount, LookupContext)
; EntryNameSyntax : DWORD -> "int"
; EntryName : LPWSTR optional -> "wstr"
; IfSpec : void* optional -> "intptr"
; ObjUuid : GUID* optional -> "var"
; BindingMaxCount : DWORD -> "int"
; LookupContext : void** out -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	rpcns4 = windows.NewLazySystemDLL("RPCNS4.dll")
	procRpcNsBindingLookupBeginW = rpcns4.NewProc("RpcNsBindingLookupBeginW")
)

// EntryNameSyntax (DWORD), EntryName (LPWSTR optional), IfSpec (void* optional), ObjUuid (GUID* optional), BindingMaxCount (DWORD), LookupContext (void** out)
r1, _, err := procRpcNsBindingLookupBeginW.Call(
	uintptr(EntryNameSyntax),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(EntryName))),
	uintptr(IfSpec),
	uintptr(ObjUuid),
	uintptr(BindingMaxCount),
	uintptr(LookupContext),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // RPC_STATUS
function RpcNsBindingLookupBeginW(
  EntryNameSyntax: DWORD;   // DWORD
  EntryName: PWideChar;   // LPWSTR optional
  IfSpec: Pointer;   // void* optional
  ObjUuid: PGUID;   // GUID* optional
  BindingMaxCount: DWORD;   // DWORD
  LookupContext: Pointer   // void** out
): Integer; stdcall;
  external 'RPCNS4.dll' name 'RpcNsBindingLookupBeginW';
result := DllCall("RPCNS4\RpcNsBindingLookupBeginW"
    , "UInt", EntryNameSyntax   ; DWORD
    , "WStr", EntryName   ; LPWSTR optional
    , "Ptr", IfSpec   ; void* optional
    , "Ptr", ObjUuid   ; GUID* optional
    , "UInt", BindingMaxCount   ; DWORD
    , "Ptr", LookupContext   ; void** out
    , "Int")   ; return: RPC_STATUS
●RpcNsBindingLookupBeginW(EntryNameSyntax, EntryName, IfSpec, ObjUuid, BindingMaxCount, LookupContext) = DLL("RPCNS4.dll", "int RpcNsBindingLookupBeginW(dword, char*, void*, void*, dword, void*)")
# 呼び出し: RpcNsBindingLookupBeginW(EntryNameSyntax, EntryName, IfSpec, ObjUuid, BindingMaxCount, LookupContext)
# EntryNameSyntax : DWORD -> "dword"
# EntryName : LPWSTR 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)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。
const std = @import("std");

extern "rpcns4" fn RpcNsBindingLookupBeginW(
    EntryNameSyntax: u32, // DWORD
    EntryName: [*c]const u16, // LPWSTR optional
    IfSpec: ?*anyopaque, // void* optional
    ObjUuid: [*c]GUID, // GUID* optional
    BindingMaxCount: u32, // DWORD
    LookupContext: ?*anyopaque // void** out
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。
proc RpcNsBindingLookupBeginW(
    EntryNameSyntax: uint32,  # DWORD
    EntryName: WideCString,  # LPWSTR optional
    IfSpec: pointer,  # void* optional
    ObjUuid: ptr GUID,  # GUID* optional
    BindingMaxCount: uint32,  # DWORD
    LookupContext: pointer  # void** out
): int32 {.importc: "RpcNsBindingLookupBeginW", stdcall, dynlib: "RPCNS4.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。
pragma(lib, "rpcns4");
extern(Windows)
int RpcNsBindingLookupBeginW(
    uint EntryNameSyntax,   // DWORD
    const(wchar)* EntryName,   // LPWSTR optional
    void* IfSpec,   // void* optional
    GUID* ObjUuid,   // GUID* optional
    uint BindingMaxCount,   // DWORD
    void** LookupContext   // void** out
);
ccall((:RpcNsBindingLookupBeginW, "RPCNS4.dll"), stdcall, Int32,
      (UInt32, Cwstring, Ptr{Cvoid}, Ptr{GUID}, UInt32, Ptr{Cvoid}),
      EntryNameSyntax, EntryName, IfSpec, ObjUuid, BindingMaxCount, LookupContext)
# EntryNameSyntax : DWORD -> UInt32
# EntryName : LPWSTR optional -> Cwstring
# IfSpec : void* optional -> Ptr{Cvoid}
# ObjUuid : GUID* optional -> Ptr{GUID}
# BindingMaxCount : DWORD -> UInt32
# LookupContext : void** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。
local ffi = require("ffi")
ffi.cdef[[
int32_t RpcNsBindingLookupBeginW(
    uint32_t EntryNameSyntax,
    const uint16_t* EntryName,
    void* IfSpec,
    void* ObjUuid,
    uint32_t BindingMaxCount,
    void** LookupContext);
]]
local rpcns4 = ffi.load("rpcns4")
-- rpcns4.RpcNsBindingLookupBeginW(EntryNameSyntax, EntryName, IfSpec, ObjUuid, BindingMaxCount, LookupContext)
-- EntryNameSyntax : DWORD
-- EntryName : LPWSTR optional
-- IfSpec : void* optional
-- ObjUuid : GUID* optional
-- BindingMaxCount : DWORD
-- LookupContext : void** out
-- 構造体/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 RpcNsBindingLookupBeginW = lib.func('__stdcall', 'RpcNsBindingLookupBeginW', 'int32_t', ['uint32_t', 'str16', 'void *', 'void *', 'uint32_t', 'void *']);
// RpcNsBindingLookupBeginW(EntryNameSyntax, EntryName, IfSpec, ObjUuid, BindingMaxCount, LookupContext)
// EntryNameSyntax : DWORD -> 'uint32_t'
// EntryName : LPWSTR optional -> 'str16'
// 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", {
  RpcNsBindingLookupBeginW: { parameters: ["u32", "buffer", "pointer", "pointer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.RpcNsBindingLookupBeginW(EntryNameSyntax, EntryName, IfSpec, ObjUuid, BindingMaxCount, LookupContext)
// EntryNameSyntax : DWORD -> "u32"
// EntryName : LPWSTR optional -> "buffer"
// IfSpec : void* optional -> "pointer"
// ObjUuid : GUID* optional -> "pointer"
// BindingMaxCount : DWORD -> "u32"
// LookupContext : void** out -> "pointer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t RpcNsBindingLookupBeginW(
    uint32_t EntryNameSyntax,
    const uint16_t* EntryName,
    void* IfSpec,
    void* ObjUuid,
    uint32_t BindingMaxCount,
    void** LookupContext);
C, "RPCNS4.dll");
// $ffi->RpcNsBindingLookupBeginW(EntryNameSyntax, EntryName, IfSpec, ObjUuid, BindingMaxCount, LookupContext);
// EntryNameSyntax : DWORD
// EntryName : LPWSTR 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.UNICODE_OPTIONS);
    int RpcNsBindingLookupBeginW(
        int EntryNameSyntax,   // DWORD
        WString EntryName,   // LPWSTR optional
        Pointer IfSpec,   // void* optional
        Pointer ObjUuid,   // GUID* optional
        int BindingMaxCount,   // DWORD
        Pointer LookupContext   // void** out
    );
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。
@[Link("rpcns4")]
lib LibRPCNS4
  fun RpcNsBindingLookupBeginW = RpcNsBindingLookupBeginW(
    EntryNameSyntax : UInt32,   # DWORD
    EntryName : UInt16*,   # LPWSTR 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 RpcNsBindingLookupBeginWNative = Int32 Function(Uint32, Pointer<Utf16>, Pointer<Void>, Pointer<Void>, Uint32, Pointer<Void>);
typedef RpcNsBindingLookupBeginWDart = int Function(int, Pointer<Utf16>, Pointer<Void>, Pointer<Void>, int, Pointer<Void>);
final RpcNsBindingLookupBeginW = DynamicLibrary.open('RPCNS4.dll')
    .lookupFunction<RpcNsBindingLookupBeginWNative, RpcNsBindingLookupBeginWDart>('RpcNsBindingLookupBeginW');
// EntryNameSyntax : DWORD -> Uint32
// EntryName : LPWSTR optional -> Pointer<Utf16>
// 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 RpcNsBindingLookupBeginW(
  EntryNameSyntax: DWORD;   // DWORD
  EntryName: PWideChar;   // LPWSTR optional
  IfSpec: Pointer;   // void* optional
  ObjUuid: PGUID;   // GUID* optional
  BindingMaxCount: DWORD;   // DWORD
  LookupContext: Pointer   // void** out
): Integer; stdcall;
  external 'RPCNS4.dll' name 'RpcNsBindingLookupBeginW';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "RpcNsBindingLookupBeginW"
  c_RpcNsBindingLookupBeginW :: Word32 -> CWString -> Ptr () -> Ptr () -> Word32 -> Ptr () -> IO Int32
-- EntryNameSyntax : DWORD -> Word32
-- EntryName : LPWSTR optional -> CWString
-- 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 rpcnsbindinglookupbeginw =
  foreign "RpcNsBindingLookupBeginW"
    (uint32_t @-> (ptr uint16_t) @-> (ptr void) @-> (ptr void) @-> uint32_t @-> (ptr void) @-> returning int32_t)
(* EntryNameSyntax : DWORD -> uint32_t *)
(* EntryName : LPWSTR optional -> (ptr uint16_t) *)
(* 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 ("RpcNsBindingLookupBeginW" rpc-ns-binding-lookup-begin-w :convention :stdcall) :int32
  (entry-name-syntax :uint32)   ; DWORD
  (entry-name (:string :encoding :utf-16le))   ; LPWSTR 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 $RpcNsBindingLookupBeginW = Win32::API::More->new('RPCNS4',
    'int RpcNsBindingLookupBeginW(DWORD EntryNameSyntax, LPCWSTR EntryName, LPVOID IfSpec, LPVOID ObjUuid, DWORD BindingMaxCount, LPVOID LookupContext)');
# my $ret = $RpcNsBindingLookupBeginW->Call($EntryNameSyntax, $EntryName, $IfSpec, $ObjUuid, $BindingMaxCount, $LookupContext);
# EntryNameSyntax : DWORD -> DWORD
# EntryName : LPWSTR optional -> LPCWSTR
# IfSpec : void* optional -> LPVOID
# ObjUuid : GUID* optional -> LPVOID
# BindingMaxCount : DWORD -> DWORD
# LookupContext : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。

関連項目

文字セット違い
公式の関連項目
使用する型