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

RpcStringBindingComposeA

関数
各要素から文字列バインディングを合成する(ANSI版)。
DLLRPCRT4.dll文字セットANSI (-A)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// RPCRT4.dll  (ANSI / -A)
#include <windows.h>

RPC_STATUS RpcStringBindingComposeA(
    LPSTR ObjUuid,   // optional
    LPSTR ProtSeq,   // optional
    LPSTR NetworkAddr,   // optional
    LPSTR Endpoint,   // optional
    LPSTR Options,   // optional
    LPSTR* StringBinding   // optional
);

パラメーター

名前方向説明
ObjUuidLPSTRinoptionalオブジェクトUUIDを示す文字列(ANSI)。NULL 可。
ProtSeqLPSTRinoptionalプロトコルシーケンスを示す文字列(ANSI)。NULL 可。
NetworkAddrLPSTRinoptionalネットワークアドレスを示す文字列(ANSI)。NULL 可。
EndpointLPSTRinoptionalエンドポイントを示す文字列(ANSI)。NULL 可。
OptionsLPSTRinoptionalネットワークオプションを示す文字列(ANSI)。NULL 可。
StringBindingLPSTR*outoptional合成された文字列バインディング(ANSI)を受け取る変数のアドレス。

戻り値の型: RPC_STATUS

各言語での呼び出し定義

// RPCRT4.dll  (ANSI / -A)
#include <windows.h>

RPC_STATUS RpcStringBindingComposeA(
    LPSTR ObjUuid,   // optional
    LPSTR ProtSeq,   // optional
    LPSTR NetworkAddr,   // optional
    LPSTR Endpoint,   // optional
    LPSTR Options,   // optional
    LPSTR* StringBinding   // optional
);
[DllImport("RPCRT4.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int RpcStringBindingComposeA(
    [MarshalAs(UnmanagedType.LPStr)] string ObjUuid,   // LPSTR optional
    [MarshalAs(UnmanagedType.LPStr)] string ProtSeq,   // LPSTR optional
    [MarshalAs(UnmanagedType.LPStr)] string NetworkAddr,   // LPSTR optional
    [MarshalAs(UnmanagedType.LPStr)] string Endpoint,   // LPSTR optional
    [MarshalAs(UnmanagedType.LPStr)] string Options,   // LPSTR optional
    IntPtr StringBinding   // LPSTR* optional, out
);
<DllImport("RPCRT4.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function RpcStringBindingComposeA(
    <MarshalAs(UnmanagedType.LPStr)> ObjUuid As String,   ' LPSTR optional
    <MarshalAs(UnmanagedType.LPStr)> ProtSeq As String,   ' LPSTR optional
    <MarshalAs(UnmanagedType.LPStr)> NetworkAddr As String,   ' LPSTR optional
    <MarshalAs(UnmanagedType.LPStr)> Endpoint As String,   ' LPSTR optional
    <MarshalAs(UnmanagedType.LPStr)> Options As String,   ' LPSTR optional
    StringBinding As IntPtr   ' LPSTR* optional, out
) As Integer
End Function
' ObjUuid : LPSTR optional
' ProtSeq : LPSTR optional
' NetworkAddr : LPSTR optional
' Endpoint : LPSTR optional
' Options : LPSTR optional
' StringBinding : LPSTR* optional, out
Declare PtrSafe Function RpcStringBindingComposeA Lib "rpcrt4" ( _
    ByVal ObjUuid As String, _
    ByVal ProtSeq As String, _
    ByVal NetworkAddr As String, _
    ByVal Endpoint As String, _
    ByVal Options As String, _
    ByVal StringBinding As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

RpcStringBindingComposeA = ctypes.windll.rpcrt4.RpcStringBindingComposeA
RpcStringBindingComposeA.restype = ctypes.c_int
RpcStringBindingComposeA.argtypes = [
    wintypes.LPCSTR,  # ObjUuid : LPSTR optional
    wintypes.LPCSTR,  # ProtSeq : LPSTR optional
    wintypes.LPCSTR,  # NetworkAddr : LPSTR optional
    wintypes.LPCSTR,  # Endpoint : LPSTR optional
    wintypes.LPCSTR,  # Options : LPSTR optional
    ctypes.c_void_p,  # StringBinding : LPSTR* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('RPCRT4.dll')
RpcStringBindingComposeA = Fiddle::Function.new(
  lib['RpcStringBindingComposeA'],
  [
    Fiddle::TYPE_VOIDP,  # ObjUuid : LPSTR optional
    Fiddle::TYPE_VOIDP,  # ProtSeq : LPSTR optional
    Fiddle::TYPE_VOIDP,  # NetworkAddr : LPSTR optional
    Fiddle::TYPE_VOIDP,  # Endpoint : LPSTR optional
    Fiddle::TYPE_VOIDP,  # Options : LPSTR optional
    Fiddle::TYPE_VOIDP,  # StringBinding : LPSTR* optional, out
  ],
  Fiddle::TYPE_INT)
#[link(name = "rpcrt4")]
extern "system" {
    fn RpcStringBindingComposeA(
        ObjUuid: *mut u8,  // LPSTR optional
        ProtSeq: *mut u8,  // LPSTR optional
        NetworkAddr: *mut u8,  // LPSTR optional
        Endpoint: *mut u8,  // LPSTR optional
        Options: *mut u8,  // LPSTR optional
        StringBinding: *mut *mut u8  // LPSTR* optional, out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("RPCRT4.dll", CharSet = CharSet.Ansi)]
public static extern int RpcStringBindingComposeA([MarshalAs(UnmanagedType.LPStr)] string ObjUuid, [MarshalAs(UnmanagedType.LPStr)] string ProtSeq, [MarshalAs(UnmanagedType.LPStr)] string NetworkAddr, [MarshalAs(UnmanagedType.LPStr)] string Endpoint, [MarshalAs(UnmanagedType.LPStr)] string Options, IntPtr StringBinding);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RPCRT4_RpcStringBindingComposeA' -Namespace Win32 -PassThru
# $api::RpcStringBindingComposeA(ObjUuid, ProtSeq, NetworkAddr, Endpoint, Options, StringBinding)
#uselib "RPCRT4.dll"
#func global RpcStringBindingComposeA "RpcStringBindingComposeA" sptr, sptr, sptr, sptr, sptr, sptr
; RpcStringBindingComposeA ObjUuid, ProtSeq, NetworkAddr, Endpoint, Options, varptr(StringBinding)   ; 戻り値は stat
; ObjUuid : LPSTR optional -> "sptr"
; ProtSeq : LPSTR optional -> "sptr"
; NetworkAddr : LPSTR optional -> "sptr"
; Endpoint : LPSTR optional -> "sptr"
; Options : LPSTR optional -> "sptr"
; StringBinding : LPSTR* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "RPCRT4.dll"
#cfunc global RpcStringBindingComposeA "RpcStringBindingComposeA" str, str, str, str, str, var
; res = RpcStringBindingComposeA(ObjUuid, ProtSeq, NetworkAddr, Endpoint, Options, StringBinding)
; ObjUuid : LPSTR optional -> "str"
; ProtSeq : LPSTR optional -> "str"
; NetworkAddr : LPSTR optional -> "str"
; Endpoint : LPSTR optional -> "str"
; Options : LPSTR optional -> "str"
; StringBinding : LPSTR* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; RPC_STATUS RpcStringBindingComposeA(LPSTR ObjUuid, LPSTR ProtSeq, LPSTR NetworkAddr, LPSTR Endpoint, LPSTR Options, LPSTR* StringBinding)
#uselib "RPCRT4.dll"
#cfunc global RpcStringBindingComposeA "RpcStringBindingComposeA" str, str, str, str, str, var
; res = RpcStringBindingComposeA(ObjUuid, ProtSeq, NetworkAddr, Endpoint, Options, StringBinding)
; ObjUuid : LPSTR optional -> "str"
; ProtSeq : LPSTR optional -> "str"
; NetworkAddr : LPSTR optional -> "str"
; Endpoint : LPSTR optional -> "str"
; Options : LPSTR optional -> "str"
; StringBinding : LPSTR* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
	procRpcStringBindingComposeA = rpcrt4.NewProc("RpcStringBindingComposeA")
)

// ObjUuid (LPSTR optional), ProtSeq (LPSTR optional), NetworkAddr (LPSTR optional), Endpoint (LPSTR optional), Options (LPSTR optional), StringBinding (LPSTR* optional, out)
r1, _, err := procRpcStringBindingComposeA.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(ObjUuid))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(ProtSeq))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(NetworkAddr))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(Endpoint))),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(Options))),
	uintptr(StringBinding),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // RPC_STATUS
function RpcStringBindingComposeA(
  ObjUuid: PAnsiChar;   // LPSTR optional
  ProtSeq: PAnsiChar;   // LPSTR optional
  NetworkAddr: PAnsiChar;   // LPSTR optional
  Endpoint: PAnsiChar;   // LPSTR optional
  Options: PAnsiChar;   // LPSTR optional
  StringBinding: PPAnsiChar   // LPSTR* optional, out
): Integer; stdcall;
  external 'RPCRT4.dll' name 'RpcStringBindingComposeA';
result := DllCall("RPCRT4\RpcStringBindingComposeA"
    , "AStr", ObjUuid   ; LPSTR optional
    , "AStr", ProtSeq   ; LPSTR optional
    , "AStr", NetworkAddr   ; LPSTR optional
    , "AStr", Endpoint   ; LPSTR optional
    , "AStr", Options   ; LPSTR optional
    , "Ptr", StringBinding   ; LPSTR* optional, out
    , "Int")   ; return: RPC_STATUS
●RpcStringBindingComposeA(ObjUuid, ProtSeq, NetworkAddr, Endpoint, Options, StringBinding) = DLL("RPCRT4.dll", "int RpcStringBindingComposeA(char*, char*, char*, char*, char*, void*)")
# 呼び出し: RpcStringBindingComposeA(ObjUuid, ProtSeq, NetworkAddr, Endpoint, Options, StringBinding)
# ObjUuid : LPSTR optional -> "char*"
# ProtSeq : LPSTR optional -> "char*"
# NetworkAddr : LPSTR optional -> "char*"
# Endpoint : LPSTR optional -> "char*"
# Options : LPSTR optional -> "char*"
# StringBinding : LPSTR* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "rpcrt4" fn RpcStringBindingComposeA(
    ObjUuid: [*c]const u8, // LPSTR optional
    ProtSeq: [*c]const u8, // LPSTR optional
    NetworkAddr: [*c]const u8, // LPSTR optional
    Endpoint: [*c]const u8, // LPSTR optional
    Options: [*c]const u8, // LPSTR optional
    StringBinding: [*c][*c]u8 // LPSTR* optional, out
) callconv(std.os.windows.WINAPI) i32;
proc RpcStringBindingComposeA(
    ObjUuid: cstring,  # LPSTR optional
    ProtSeq: cstring,  # LPSTR optional
    NetworkAddr: cstring,  # LPSTR optional
    Endpoint: cstring,  # LPSTR optional
    Options: cstring,  # LPSTR optional
    StringBinding: ptr cstring  # LPSTR* optional, out
): int32 {.importc: "RpcStringBindingComposeA", stdcall, dynlib: "RPCRT4.dll".}
pragma(lib, "rpcrt4");
extern(Windows)
int RpcStringBindingComposeA(
    const(char)* ObjUuid,   // LPSTR optional
    const(char)* ProtSeq,   // LPSTR optional
    const(char)* NetworkAddr,   // LPSTR optional
    const(char)* Endpoint,   // LPSTR optional
    const(char)* Options,   // LPSTR optional
    char** StringBinding   // LPSTR* optional, out
);
ccall((:RpcStringBindingComposeA, "RPCRT4.dll"), stdcall, Int32,
      (Cstring, Cstring, Cstring, Cstring, Cstring, Ptr{Ptr{UInt8}}),
      ObjUuid, ProtSeq, NetworkAddr, Endpoint, Options, StringBinding)
# ObjUuid : LPSTR optional -> Cstring
# ProtSeq : LPSTR optional -> Cstring
# NetworkAddr : LPSTR optional -> Cstring
# Endpoint : LPSTR optional -> Cstring
# Options : LPSTR optional -> Cstring
# StringBinding : LPSTR* optional, out -> Ptr{Ptr{UInt8}}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t RpcStringBindingComposeA(
    const char* ObjUuid,
    const char* ProtSeq,
    const char* NetworkAddr,
    const char* Endpoint,
    const char* Options,
    char** StringBinding);
]]
local rpcrt4 = ffi.load("rpcrt4")
-- rpcrt4.RpcStringBindingComposeA(ObjUuid, ProtSeq, NetworkAddr, Endpoint, Options, StringBinding)
-- ObjUuid : LPSTR optional
-- ProtSeq : LPSTR optional
-- NetworkAddr : LPSTR optional
-- Endpoint : LPSTR optional
-- Options : LPSTR optional
-- StringBinding : LPSTR* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('RPCRT4.dll');
const RpcStringBindingComposeA = lib.func('__stdcall', 'RpcStringBindingComposeA', 'int32_t', ['str', 'str', 'str', 'str', 'str', 'void *']);
// RpcStringBindingComposeA(ObjUuid, ProtSeq, NetworkAddr, Endpoint, Options, StringBinding)
// ObjUuid : LPSTR optional -> 'str'
// ProtSeq : LPSTR optional -> 'str'
// NetworkAddr : LPSTR optional -> 'str'
// Endpoint : LPSTR optional -> 'str'
// Options : LPSTR optional -> 'str'
// StringBinding : LPSTR* optional, out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("RPCRT4.dll", {
  RpcStringBindingComposeA: { parameters: ["buffer", "buffer", "buffer", "buffer", "buffer", "pointer"], result: "i32" },
});
// lib.symbols.RpcStringBindingComposeA(ObjUuid, ProtSeq, NetworkAddr, Endpoint, Options, StringBinding)
// ObjUuid : LPSTR optional -> "buffer"
// ProtSeq : LPSTR optional -> "buffer"
// NetworkAddr : LPSTR optional -> "buffer"
// Endpoint : LPSTR optional -> "buffer"
// Options : LPSTR optional -> "buffer"
// StringBinding : LPSTR* optional, out -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t RpcStringBindingComposeA(
    const char* ObjUuid,
    const char* ProtSeq,
    const char* NetworkAddr,
    const char* Endpoint,
    const char* Options,
    char** StringBinding);
C, "RPCRT4.dll");
// $ffi->RpcStringBindingComposeA(ObjUuid, ProtSeq, NetworkAddr, Endpoint, Options, StringBinding);
// ObjUuid : LPSTR optional
// ProtSeq : LPSTR optional
// NetworkAddr : LPSTR optional
// Endpoint : LPSTR optional
// Options : LPSTR optional
// StringBinding : LPSTR* optional, 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 RpcStringBindingComposeA(
        String ObjUuid,   // LPSTR optional
        String ProtSeq,   // LPSTR optional
        String NetworkAddr,   // LPSTR optional
        String Endpoint,   // LPSTR optional
        String Options,   // LPSTR optional
        PointerByReference StringBinding   // LPSTR* optional, out
    );
}
@[Link("rpcrt4")]
lib LibRPCRT4
  fun RpcStringBindingComposeA = RpcStringBindingComposeA(
    ObjUuid : UInt8*,   # LPSTR optional
    ProtSeq : UInt8*,   # LPSTR optional
    NetworkAddr : UInt8*,   # LPSTR optional
    Endpoint : UInt8*,   # LPSTR optional
    Options : UInt8*,   # LPSTR optional
    StringBinding : UInt8**   # LPSTR* optional, out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef RpcStringBindingComposeANative = Int32 Function(Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Pointer<Utf8>>);
typedef RpcStringBindingComposeADart = int Function(Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Utf8>, Pointer<Pointer<Utf8>>);
final RpcStringBindingComposeA = DynamicLibrary.open('RPCRT4.dll')
    .lookupFunction<RpcStringBindingComposeANative, RpcStringBindingComposeADart>('RpcStringBindingComposeA');
// ObjUuid : LPSTR optional -> Pointer<Utf8>
// ProtSeq : LPSTR optional -> Pointer<Utf8>
// NetworkAddr : LPSTR optional -> Pointer<Utf8>
// Endpoint : LPSTR optional -> Pointer<Utf8>
// Options : LPSTR optional -> Pointer<Utf8>
// StringBinding : LPSTR* optional, out -> Pointer<Pointer<Utf8>>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function RpcStringBindingComposeA(
  ObjUuid: PAnsiChar;   // LPSTR optional
  ProtSeq: PAnsiChar;   // LPSTR optional
  NetworkAddr: PAnsiChar;   // LPSTR optional
  Endpoint: PAnsiChar;   // LPSTR optional
  Options: PAnsiChar;   // LPSTR optional
  StringBinding: PPAnsiChar   // LPSTR* optional, out
): Integer; stdcall;
  external 'RPCRT4.dll' name 'RpcStringBindingComposeA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "RpcStringBindingComposeA"
  c_RpcStringBindingComposeA :: CString -> CString -> CString -> CString -> CString -> Ptr CString -> IO Int32
-- ObjUuid : LPSTR optional -> CString
-- ProtSeq : LPSTR optional -> CString
-- NetworkAddr : LPSTR optional -> CString
-- Endpoint : LPSTR optional -> CString
-- Options : LPSTR optional -> CString
-- StringBinding : LPSTR* optional, out -> Ptr CString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let rpcstringbindingcomposea =
  foreign "RpcStringBindingComposeA"
    (string @-> string @-> string @-> string @-> string @-> (ptr string) @-> returning int32_t)
(* ObjUuid : LPSTR optional -> string *)
(* ProtSeq : LPSTR optional -> string *)
(* NetworkAddr : LPSTR optional -> string *)
(* Endpoint : LPSTR optional -> string *)
(* Options : LPSTR optional -> string *)
(* StringBinding : LPSTR* optional, out -> (ptr string) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library rpcrt4 (t "RPCRT4.dll"))
(cffi:use-foreign-library rpcrt4)

(cffi:defcfun ("RpcStringBindingComposeA" rpc-string-binding-compose-a :convention :stdcall) :int32
  (obj-uuid :string)   ; LPSTR optional
  (prot-seq :string)   ; LPSTR optional
  (network-addr :string)   ; LPSTR optional
  (endpoint :string)   ; LPSTR optional
  (options :string)   ; LPSTR optional
  (string-binding :pointer))   ; LPSTR* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $RpcStringBindingComposeA = Win32::API::More->new('RPCRT4',
    'int RpcStringBindingComposeA(LPCSTR ObjUuid, LPCSTR ProtSeq, LPCSTR NetworkAddr, LPCSTR Endpoint, LPCSTR Options, LPVOID StringBinding)');
# my $ret = $RpcStringBindingComposeA->Call($ObjUuid, $ProtSeq, $NetworkAddr, $Endpoint, $Options, $StringBinding);
# ObjUuid : LPSTR optional -> LPCSTR
# ProtSeq : LPSTR optional -> LPCSTR
# NetworkAddr : LPSTR optional -> LPCSTR
# Endpoint : LPSTR optional -> LPCSTR
# Options : LPSTR optional -> LPCSTR
# StringBinding : LPSTR* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

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