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

I_RpcBindingCreateNP

関数
名前付きパイプ用のバインディングハンドルを作成する内部関数。
DLLRPCRT4.dll呼出規約winapi

シグネチャ

// RPCRT4.dll
#include <windows.h>

RPC_STATUS I_RpcBindingCreateNP(
    LPWSTR ServerName,
    LPWSTR ServiceName,
    LPWSTR NetworkOptions,
    void** Binding
);

パラメーター

名前方向
ServerNameLPWSTRin
ServiceNameLPWSTRin
NetworkOptionsLPWSTRin
Bindingvoid**out

戻り値の型: RPC_STATUS

各言語での呼び出し定義

// RPCRT4.dll
#include <windows.h>

RPC_STATUS I_RpcBindingCreateNP(
    LPWSTR ServerName,
    LPWSTR ServiceName,
    LPWSTR NetworkOptions,
    void** Binding
);
[DllImport("RPCRT4.dll", ExactSpelling = true)]
static extern int I_RpcBindingCreateNP(
    [MarshalAs(UnmanagedType.LPWStr)] string ServerName,   // LPWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string ServiceName,   // LPWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string NetworkOptions,   // LPWSTR
    IntPtr Binding   // void** out
);
<DllImport("RPCRT4.dll", ExactSpelling:=True)>
Public Shared Function I_RpcBindingCreateNP(
    <MarshalAs(UnmanagedType.LPWStr)> ServerName As String,   ' LPWSTR
    <MarshalAs(UnmanagedType.LPWStr)> ServiceName As String,   ' LPWSTR
    <MarshalAs(UnmanagedType.LPWStr)> NetworkOptions As String,   ' LPWSTR
    Binding As IntPtr   ' void** out
) As Integer
End Function
' ServerName : LPWSTR
' ServiceName : LPWSTR
' NetworkOptions : LPWSTR
' Binding : void** out
Declare PtrSafe Function I_RpcBindingCreateNP Lib "rpcrt4" ( _
    ByVal ServerName As LongPtr, _
    ByVal ServiceName As LongPtr, _
    ByVal NetworkOptions 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

I_RpcBindingCreateNP = ctypes.windll.rpcrt4.I_RpcBindingCreateNP
I_RpcBindingCreateNP.restype = ctypes.c_int
I_RpcBindingCreateNP.argtypes = [
    wintypes.LPCWSTR,  # ServerName : LPWSTR
    wintypes.LPCWSTR,  # ServiceName : LPWSTR
    wintypes.LPCWSTR,  # NetworkOptions : LPWSTR
    ctypes.c_void_p,  # Binding : void** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('RPCRT4.dll')
I_RpcBindingCreateNP = Fiddle::Function.new(
  lib['I_RpcBindingCreateNP'],
  [
    Fiddle::TYPE_VOIDP,  # ServerName : LPWSTR
    Fiddle::TYPE_VOIDP,  # ServiceName : LPWSTR
    Fiddle::TYPE_VOIDP,  # NetworkOptions : LPWSTR
    Fiddle::TYPE_VOIDP,  # Binding : void** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "rpcrt4")]
extern "system" {
    fn I_RpcBindingCreateNP(
        ServerName: *mut u16,  // LPWSTR
        ServiceName: *mut u16,  // LPWSTR
        NetworkOptions: *mut u16,  // LPWSTR
        Binding: *mut *mut ()  // void** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("RPCRT4.dll")]
public static extern int I_RpcBindingCreateNP([MarshalAs(UnmanagedType.LPWStr)] string ServerName, [MarshalAs(UnmanagedType.LPWStr)] string ServiceName, [MarshalAs(UnmanagedType.LPWStr)] string NetworkOptions, IntPtr Binding);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RPCRT4_I_RpcBindingCreateNP' -Namespace Win32 -PassThru
# $api::I_RpcBindingCreateNP(ServerName, ServiceName, NetworkOptions, Binding)
#uselib "RPCRT4.dll"
#func global I_RpcBindingCreateNP "I_RpcBindingCreateNP" sptr, sptr, sptr, sptr
; I_RpcBindingCreateNP ServerName, ServiceName, NetworkOptions, Binding   ; 戻り値は stat
; ServerName : LPWSTR -> "sptr"
; ServiceName : LPWSTR -> "sptr"
; NetworkOptions : LPWSTR -> "sptr"
; Binding : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "RPCRT4.dll"
#cfunc global I_RpcBindingCreateNP "I_RpcBindingCreateNP" wstr, wstr, wstr, sptr
; res = I_RpcBindingCreateNP(ServerName, ServiceName, NetworkOptions, Binding)
; ServerName : LPWSTR -> "wstr"
; ServiceName : LPWSTR -> "wstr"
; NetworkOptions : LPWSTR -> "wstr"
; Binding : void** out -> "sptr"
; RPC_STATUS I_RpcBindingCreateNP(LPWSTR ServerName, LPWSTR ServiceName, LPWSTR NetworkOptions, void** Binding)
#uselib "RPCRT4.dll"
#cfunc global I_RpcBindingCreateNP "I_RpcBindingCreateNP" wstr, wstr, wstr, intptr
; res = I_RpcBindingCreateNP(ServerName, ServiceName, NetworkOptions, Binding)
; ServerName : LPWSTR -> "wstr"
; ServiceName : LPWSTR -> "wstr"
; NetworkOptions : LPWSTR -> "wstr"
; Binding : void** out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
	procI_RpcBindingCreateNP = rpcrt4.NewProc("I_RpcBindingCreateNP")
)

// ServerName (LPWSTR), ServiceName (LPWSTR), NetworkOptions (LPWSTR), Binding (void** out)
r1, _, err := procI_RpcBindingCreateNP.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ServerName))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ServiceName))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(NetworkOptions))),
	uintptr(Binding),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // RPC_STATUS
function I_RpcBindingCreateNP(
  ServerName: PWideChar;   // LPWSTR
  ServiceName: PWideChar;   // LPWSTR
  NetworkOptions: PWideChar;   // LPWSTR
  Binding: Pointer   // void** out
): Integer; stdcall;
  external 'RPCRT4.dll' name 'I_RpcBindingCreateNP';
result := DllCall("RPCRT4\I_RpcBindingCreateNP"
    , "WStr", ServerName   ; LPWSTR
    , "WStr", ServiceName   ; LPWSTR
    , "WStr", NetworkOptions   ; LPWSTR
    , "Ptr", Binding   ; void** out
    , "Int")   ; return: RPC_STATUS
●I_RpcBindingCreateNP(ServerName, ServiceName, NetworkOptions, Binding) = DLL("RPCRT4.dll", "int I_RpcBindingCreateNP(char*, char*, char*, void*)")
# 呼び出し: I_RpcBindingCreateNP(ServerName, ServiceName, NetworkOptions, Binding)
# ServerName : LPWSTR -> "char*"
# ServiceName : LPWSTR -> "char*"
# NetworkOptions : LPWSTR -> "char*"
# Binding : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。