ホーム › System.Rpc › RpcBindingCreateA
RpcBindingCreateA
関数テンプレートからバインディングを作成する(ANSI版)。
シグネチャ
// RPCRT4.dll (ANSI / -A)
#include <windows.h>
RPC_STATUS RpcBindingCreateA(
RPC_BINDING_HANDLE_TEMPLATE_V1_A* Template,
RPC_BINDING_HANDLE_SECURITY_V1_A* Security, // optional
RPC_BINDING_HANDLE_OPTIONS_V1* Options, // optional
void** Binding
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| Template | RPC_BINDING_HANDLE_TEMPLATE_V1_A* | in | サーバーアドレス/プロトコル等を指定するバインディングテンプレート構造体(ANSI)へのポインタ。 |
| Security | RPC_BINDING_HANDLE_SECURITY_V1_A* | inoptional | 認証情報を指定するセキュリティ構造体(ANSI)へのポインタ。NULL可。 |
| Options | RPC_BINDING_HANDLE_OPTIONS_V1* | inoptional | タイムアウト等のオプションを指定するRPC_BINDING_HANDLE_OPTIONS構造体へのポインタ。NULL可。 |
| Binding | void** | out | 作成されたバインディングハンドルを受け取る出力先ポインタのアドレス。 |
戻り値の型: RPC_STATUS
各言語での呼び出し定義
// RPCRT4.dll (ANSI / -A)
#include <windows.h>
RPC_STATUS RpcBindingCreateA(
RPC_BINDING_HANDLE_TEMPLATE_V1_A* Template,
RPC_BINDING_HANDLE_SECURITY_V1_A* Security, // optional
RPC_BINDING_HANDLE_OPTIONS_V1* Options, // optional
void** Binding
);[DllImport("RPCRT4.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int RpcBindingCreateA(
IntPtr Template, // RPC_BINDING_HANDLE_TEMPLATE_V1_A*
IntPtr Security, // RPC_BINDING_HANDLE_SECURITY_V1_A* optional
IntPtr Options, // RPC_BINDING_HANDLE_OPTIONS_V1* optional
IntPtr Binding // void** out
);<DllImport("RPCRT4.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function RpcBindingCreateA(
Template As IntPtr, ' RPC_BINDING_HANDLE_TEMPLATE_V1_A*
Security As IntPtr, ' RPC_BINDING_HANDLE_SECURITY_V1_A* optional
Options As IntPtr, ' RPC_BINDING_HANDLE_OPTIONS_V1* optional
Binding As IntPtr ' void** out
) As Integer
End Function' Template : RPC_BINDING_HANDLE_TEMPLATE_V1_A*
' Security : RPC_BINDING_HANDLE_SECURITY_V1_A* optional
' Options : RPC_BINDING_HANDLE_OPTIONS_V1* optional
' Binding : void** out
Declare PtrSafe Function RpcBindingCreateA Lib "rpcrt4" ( _
ByVal Template As LongPtr, _
ByVal Security As LongPtr, _
ByVal Options As LongPtr, _
ByVal Binding As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RpcBindingCreateA = ctypes.windll.rpcrt4.RpcBindingCreateA
RpcBindingCreateA.restype = ctypes.c_int
RpcBindingCreateA.argtypes = [
ctypes.c_void_p, # Template : RPC_BINDING_HANDLE_TEMPLATE_V1_A*
ctypes.c_void_p, # Security : RPC_BINDING_HANDLE_SECURITY_V1_A* optional
ctypes.c_void_p, # Options : RPC_BINDING_HANDLE_OPTIONS_V1* optional
ctypes.c_void_p, # Binding : void** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('RPCRT4.dll')
RpcBindingCreateA = Fiddle::Function.new(
lib['RpcBindingCreateA'],
[
Fiddle::TYPE_VOIDP, # Template : RPC_BINDING_HANDLE_TEMPLATE_V1_A*
Fiddle::TYPE_VOIDP, # Security : RPC_BINDING_HANDLE_SECURITY_V1_A* optional
Fiddle::TYPE_VOIDP, # Options : RPC_BINDING_HANDLE_OPTIONS_V1* optional
Fiddle::TYPE_VOIDP, # Binding : void** out
],
Fiddle::TYPE_INT)#[link(name = "rpcrt4")]
extern "system" {
fn RpcBindingCreateA(
Template: *mut RPC_BINDING_HANDLE_TEMPLATE_V1_A, // RPC_BINDING_HANDLE_TEMPLATE_V1_A*
Security: *mut RPC_BINDING_HANDLE_SECURITY_V1_A, // RPC_BINDING_HANDLE_SECURITY_V1_A* optional
Options: *mut RPC_BINDING_HANDLE_OPTIONS_V1, // RPC_BINDING_HANDLE_OPTIONS_V1* optional
Binding: *mut *mut () // void** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("RPCRT4.dll", CharSet = CharSet.Ansi)]
public static extern int RpcBindingCreateA(IntPtr Template, IntPtr Security, IntPtr Options, IntPtr Binding);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RPCRT4_RpcBindingCreateA' -Namespace Win32 -PassThru
# $api::RpcBindingCreateA(Template, Security, Options, Binding)#uselib "RPCRT4.dll"
#func global RpcBindingCreateA "RpcBindingCreateA" sptr, sptr, sptr, sptr
; RpcBindingCreateA varptr(Template), varptr(Security), varptr(Options), Binding ; 戻り値は stat
; Template : RPC_BINDING_HANDLE_TEMPLATE_V1_A* -> "sptr"
; Security : RPC_BINDING_HANDLE_SECURITY_V1_A* optional -> "sptr"
; Options : RPC_BINDING_HANDLE_OPTIONS_V1* optional -> "sptr"
; Binding : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "RPCRT4.dll" #cfunc global RpcBindingCreateA "RpcBindingCreateA" var, var, var, sptr ; res = RpcBindingCreateA(Template, Security, Options, Binding) ; Template : RPC_BINDING_HANDLE_TEMPLATE_V1_A* -> "var" ; Security : RPC_BINDING_HANDLE_SECURITY_V1_A* optional -> "var" ; Options : RPC_BINDING_HANDLE_OPTIONS_V1* optional -> "var" ; Binding : void** out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "RPCRT4.dll" #cfunc global RpcBindingCreateA "RpcBindingCreateA" sptr, sptr, sptr, sptr ; res = RpcBindingCreateA(varptr(Template), varptr(Security), varptr(Options), Binding) ; Template : RPC_BINDING_HANDLE_TEMPLATE_V1_A* -> "sptr" ; Security : RPC_BINDING_HANDLE_SECURITY_V1_A* optional -> "sptr" ; Options : RPC_BINDING_HANDLE_OPTIONS_V1* optional -> "sptr" ; Binding : void** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; RPC_STATUS RpcBindingCreateA(RPC_BINDING_HANDLE_TEMPLATE_V1_A* Template, RPC_BINDING_HANDLE_SECURITY_V1_A* Security, RPC_BINDING_HANDLE_OPTIONS_V1* Options, void** Binding) #uselib "RPCRT4.dll" #cfunc global RpcBindingCreateA "RpcBindingCreateA" var, var, var, intptr ; res = RpcBindingCreateA(Template, Security, Options, Binding) ; Template : RPC_BINDING_HANDLE_TEMPLATE_V1_A* -> "var" ; Security : RPC_BINDING_HANDLE_SECURITY_V1_A* optional -> "var" ; Options : RPC_BINDING_HANDLE_OPTIONS_V1* optional -> "var" ; Binding : void** out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; RPC_STATUS RpcBindingCreateA(RPC_BINDING_HANDLE_TEMPLATE_V1_A* Template, RPC_BINDING_HANDLE_SECURITY_V1_A* Security, RPC_BINDING_HANDLE_OPTIONS_V1* Options, void** Binding) #uselib "RPCRT4.dll" #cfunc global RpcBindingCreateA "RpcBindingCreateA" intptr, intptr, intptr, intptr ; res = RpcBindingCreateA(varptr(Template), varptr(Security), varptr(Options), Binding) ; Template : RPC_BINDING_HANDLE_TEMPLATE_V1_A* -> "intptr" ; Security : RPC_BINDING_HANDLE_SECURITY_V1_A* optional -> "intptr" ; Options : RPC_BINDING_HANDLE_OPTIONS_V1* optional -> "intptr" ; Binding : void** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
procRpcBindingCreateA = rpcrt4.NewProc("RpcBindingCreateA")
)
// Template (RPC_BINDING_HANDLE_TEMPLATE_V1_A*), Security (RPC_BINDING_HANDLE_SECURITY_V1_A* optional), Options (RPC_BINDING_HANDLE_OPTIONS_V1* optional), Binding (void** out)
r1, _, err := procRpcBindingCreateA.Call(
uintptr(Template),
uintptr(Security),
uintptr(Options),
uintptr(Binding),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // RPC_STATUSfunction RpcBindingCreateA(
Template: Pointer; // RPC_BINDING_HANDLE_TEMPLATE_V1_A*
Security: Pointer; // RPC_BINDING_HANDLE_SECURITY_V1_A* optional
Options: Pointer; // RPC_BINDING_HANDLE_OPTIONS_V1* optional
Binding: Pointer // void** out
): Integer; stdcall;
external 'RPCRT4.dll' name 'RpcBindingCreateA';result := DllCall("RPCRT4\RpcBindingCreateA"
, "Ptr", Template ; RPC_BINDING_HANDLE_TEMPLATE_V1_A*
, "Ptr", Security ; RPC_BINDING_HANDLE_SECURITY_V1_A* optional
, "Ptr", Options ; RPC_BINDING_HANDLE_OPTIONS_V1* optional
, "Ptr", Binding ; void** out
, "Int") ; return: RPC_STATUS●RpcBindingCreateA(Template, Security, Options, Binding) = DLL("RPCRT4.dll", "int RpcBindingCreateA(void*, void*, void*, void*)")
# 呼び出し: RpcBindingCreateA(Template, Security, Options, Binding)
# Template : RPC_BINDING_HANDLE_TEMPLATE_V1_A* -> "void*"
# Security : RPC_BINDING_HANDLE_SECURITY_V1_A* optional -> "void*"
# Options : RPC_BINDING_HANDLE_OPTIONS_V1* optional -> "void*"
# Binding : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "rpcrt4" fn RpcBindingCreateA(
Template: [*c]RPC_BINDING_HANDLE_TEMPLATE_V1_A, // RPC_BINDING_HANDLE_TEMPLATE_V1_A*
Security: [*c]RPC_BINDING_HANDLE_SECURITY_V1_A, // RPC_BINDING_HANDLE_SECURITY_V1_A* optional
Options: [*c]RPC_BINDING_HANDLE_OPTIONS_V1, // RPC_BINDING_HANDLE_OPTIONS_V1* optional
Binding: ?*anyopaque // void** out
) callconv(std.os.windows.WINAPI) i32;proc RpcBindingCreateA(
Template: ptr RPC_BINDING_HANDLE_TEMPLATE_V1_A, # RPC_BINDING_HANDLE_TEMPLATE_V1_A*
Security: ptr RPC_BINDING_HANDLE_SECURITY_V1_A, # RPC_BINDING_HANDLE_SECURITY_V1_A* optional
Options: ptr RPC_BINDING_HANDLE_OPTIONS_V1, # RPC_BINDING_HANDLE_OPTIONS_V1* optional
Binding: pointer # void** out
): int32 {.importc: "RpcBindingCreateA", stdcall, dynlib: "RPCRT4.dll".}pragma(lib, "rpcrt4");
extern(Windows)
int RpcBindingCreateA(
RPC_BINDING_HANDLE_TEMPLATE_V1_A* Template, // RPC_BINDING_HANDLE_TEMPLATE_V1_A*
RPC_BINDING_HANDLE_SECURITY_V1_A* Security, // RPC_BINDING_HANDLE_SECURITY_V1_A* optional
RPC_BINDING_HANDLE_OPTIONS_V1* Options, // RPC_BINDING_HANDLE_OPTIONS_V1* optional
void** Binding // void** out
);ccall((:RpcBindingCreateA, "RPCRT4.dll"), stdcall, Int32,
(Ptr{RPC_BINDING_HANDLE_TEMPLATE_V1_A}, Ptr{RPC_BINDING_HANDLE_SECURITY_V1_A}, Ptr{RPC_BINDING_HANDLE_OPTIONS_V1}, Ptr{Cvoid}),
Template, Security, Options, Binding)
# Template : RPC_BINDING_HANDLE_TEMPLATE_V1_A* -> Ptr{RPC_BINDING_HANDLE_TEMPLATE_V1_A}
# Security : RPC_BINDING_HANDLE_SECURITY_V1_A* optional -> Ptr{RPC_BINDING_HANDLE_SECURITY_V1_A}
# Options : RPC_BINDING_HANDLE_OPTIONS_V1* optional -> Ptr{RPC_BINDING_HANDLE_OPTIONS_V1}
# Binding : void** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t RpcBindingCreateA(
void* Template,
void* Security,
void* Options,
void** Binding);
]]
local rpcrt4 = ffi.load("rpcrt4")
-- rpcrt4.RpcBindingCreateA(Template, Security, Options, Binding)
-- Template : RPC_BINDING_HANDLE_TEMPLATE_V1_A*
-- Security : RPC_BINDING_HANDLE_SECURITY_V1_A* optional
-- Options : RPC_BINDING_HANDLE_OPTIONS_V1* optional
-- Binding : void** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('RPCRT4.dll');
const RpcBindingCreateA = lib.func('__stdcall', 'RpcBindingCreateA', 'int32_t', ['void *', 'void *', 'void *', 'void *']);
// RpcBindingCreateA(Template, Security, Options, Binding)
// Template : RPC_BINDING_HANDLE_TEMPLATE_V1_A* -> 'void *'
// Security : RPC_BINDING_HANDLE_SECURITY_V1_A* optional -> 'void *'
// Options : RPC_BINDING_HANDLE_OPTIONS_V1* optional -> 'void *'
// Binding : void** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("RPCRT4.dll", {
RpcBindingCreateA: { parameters: ["pointer", "pointer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.RpcBindingCreateA(Template, Security, Options, Binding)
// Template : RPC_BINDING_HANDLE_TEMPLATE_V1_A* -> "pointer"
// Security : RPC_BINDING_HANDLE_SECURITY_V1_A* optional -> "pointer"
// Options : RPC_BINDING_HANDLE_OPTIONS_V1* optional -> "pointer"
// Binding : void** out -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t RpcBindingCreateA(
void* Template,
void* Security,
void* Options,
void** Binding);
C, "RPCRT4.dll");
// $ffi->RpcBindingCreateA(Template, Security, Options, Binding);
// Template : RPC_BINDING_HANDLE_TEMPLATE_V1_A*
// Security : RPC_BINDING_HANDLE_SECURITY_V1_A* optional
// Options : RPC_BINDING_HANDLE_OPTIONS_V1* optional
// Binding : 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 Rpcrt4 extends StdCallLibrary {
Rpcrt4 INSTANCE = Native.load("rpcrt4", Rpcrt4.class, W32APIOptions.ASCII_OPTIONS);
int RpcBindingCreateA(
Pointer Template, // RPC_BINDING_HANDLE_TEMPLATE_V1_A*
Pointer Security, // RPC_BINDING_HANDLE_SECURITY_V1_A* optional
Pointer Options, // RPC_BINDING_HANDLE_OPTIONS_V1* optional
Pointer Binding // void** out
);
}@[Link("rpcrt4")]
lib LibRPCRT4
fun RpcBindingCreateA = RpcBindingCreateA(
Template : RPC_BINDING_HANDLE_TEMPLATE_V1_A*, # RPC_BINDING_HANDLE_TEMPLATE_V1_A*
Security : RPC_BINDING_HANDLE_SECURITY_V1_A*, # RPC_BINDING_HANDLE_SECURITY_V1_A* optional
Options : RPC_BINDING_HANDLE_OPTIONS_V1*, # RPC_BINDING_HANDLE_OPTIONS_V1* optional
Binding : 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 RpcBindingCreateANative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
typedef RpcBindingCreateADart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Void>, Pointer<Void>);
final RpcBindingCreateA = DynamicLibrary.open('RPCRT4.dll')
.lookupFunction<RpcBindingCreateANative, RpcBindingCreateADart>('RpcBindingCreateA');
// Template : RPC_BINDING_HANDLE_TEMPLATE_V1_A* -> Pointer<Void>
// Security : RPC_BINDING_HANDLE_SECURITY_V1_A* optional -> Pointer<Void>
// Options : RPC_BINDING_HANDLE_OPTIONS_V1* optional -> Pointer<Void>
// Binding : void** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function RpcBindingCreateA(
Template: Pointer; // RPC_BINDING_HANDLE_TEMPLATE_V1_A*
Security: Pointer; // RPC_BINDING_HANDLE_SECURITY_V1_A* optional
Options: Pointer; // RPC_BINDING_HANDLE_OPTIONS_V1* optional
Binding: Pointer // void** out
): Integer; stdcall;
external 'RPCRT4.dll' name 'RpcBindingCreateA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RpcBindingCreateA"
c_RpcBindingCreateA :: Ptr () -> Ptr () -> Ptr () -> Ptr () -> IO Int32
-- Template : RPC_BINDING_HANDLE_TEMPLATE_V1_A* -> Ptr ()
-- Security : RPC_BINDING_HANDLE_SECURITY_V1_A* optional -> Ptr ()
-- Options : RPC_BINDING_HANDLE_OPTIONS_V1* optional -> Ptr ()
-- Binding : void** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let rpcbindingcreatea =
foreign "RpcBindingCreateA"
((ptr void) @-> (ptr void) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* Template : RPC_BINDING_HANDLE_TEMPLATE_V1_A* -> (ptr void) *)
(* Security : RPC_BINDING_HANDLE_SECURITY_V1_A* optional -> (ptr void) *)
(* Options : RPC_BINDING_HANDLE_OPTIONS_V1* optional -> (ptr void) *)
(* Binding : void** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library rpcrt4 (t "RPCRT4.dll"))
(cffi:use-foreign-library rpcrt4)
(cffi:defcfun ("RpcBindingCreateA" rpc-binding-create-a :convention :stdcall) :int32
(template :pointer) ; RPC_BINDING_HANDLE_TEMPLATE_V1_A*
(security :pointer) ; RPC_BINDING_HANDLE_SECURITY_V1_A* optional
(options :pointer) ; RPC_BINDING_HANDLE_OPTIONS_V1* optional
(binding :pointer)) ; void** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RpcBindingCreateA = Win32::API::More->new('RPCRT4',
'int RpcBindingCreateA(LPVOID Template, LPVOID Security, LPVOID Options, LPVOID Binding)');
# my $ret = $RpcBindingCreateA->Call($Template, $Security, $Options, $Binding);
# Template : RPC_BINDING_HANDLE_TEMPLATE_V1_A* -> LPVOID
# Security : RPC_BINDING_HANDLE_SECURITY_V1_A* optional -> LPVOID
# Options : RPC_BINDING_HANDLE_OPTIONS_V1* optional -> LPVOID
# Binding : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f RpcBindingCreateW (Unicode版) — テンプレートからバインディングを作成する(Unicode版)。