ホーム › System.Rpc › RpcBindingSetOption
RpcBindingSetOption
関数RPCバインディングにオプションを設定する。
シグネチャ
// RPCRT4.dll
#include <windows.h>
RPC_STATUS RpcBindingSetOption(
void* hBinding,
DWORD option,
UINT_PTR optionValue
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hBinding | void* | in | オプションを設定する対象のバインディングハンドル。 |
| option | DWORD | in | 設定するバインディングオプションの種類を示す値。 |
| optionValue | UINT_PTR | in | オプションに設定する値。 |
戻り値の型: RPC_STATUS
各言語での呼び出し定義
// RPCRT4.dll
#include <windows.h>
RPC_STATUS RpcBindingSetOption(
void* hBinding,
DWORD option,
UINT_PTR optionValue
);[DllImport("RPCRT4.dll", ExactSpelling = true)]
static extern int RpcBindingSetOption(
IntPtr hBinding, // void*
uint option, // DWORD
UIntPtr optionValue // UINT_PTR
);<DllImport("RPCRT4.dll", ExactSpelling:=True)>
Public Shared Function RpcBindingSetOption(
hBinding As IntPtr, ' void*
[option] As UInteger, ' DWORD
optionValue As UIntPtr ' UINT_PTR
) As Integer
End Function' hBinding : void*
' option : DWORD
' optionValue : UINT_PTR
Declare PtrSafe Function RpcBindingSetOption Lib "rpcrt4" ( _
ByVal hBinding As LongPtr, _
ByVal option As Long, _
ByVal optionValue As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RpcBindingSetOption = ctypes.windll.rpcrt4.RpcBindingSetOption
RpcBindingSetOption.restype = ctypes.c_int
RpcBindingSetOption.argtypes = [
ctypes.POINTER(None), # hBinding : void*
wintypes.DWORD, # option : DWORD
ctypes.c_size_t, # optionValue : UINT_PTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('RPCRT4.dll')
RpcBindingSetOption = Fiddle::Function.new(
lib['RpcBindingSetOption'],
[
Fiddle::TYPE_VOIDP, # hBinding : void*
-Fiddle::TYPE_INT, # option : DWORD
Fiddle::TYPE_UINTPTR_T, # optionValue : UINT_PTR
],
Fiddle::TYPE_INT)#[link(name = "rpcrt4")]
extern "system" {
fn RpcBindingSetOption(
hBinding: *mut (), // void*
option: u32, // DWORD
optionValue: usize // UINT_PTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("RPCRT4.dll")]
public static extern int RpcBindingSetOption(IntPtr hBinding, uint option, UIntPtr optionValue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RPCRT4_RpcBindingSetOption' -Namespace Win32 -PassThru
# $api::RpcBindingSetOption(hBinding, option, optionValue)#uselib "RPCRT4.dll"
#func global RpcBindingSetOption "RpcBindingSetOption" sptr, sptr, sptr
; RpcBindingSetOption hBinding, option, optionValue ; 戻り値は stat
; hBinding : void* -> "sptr"
; option : DWORD -> "sptr"
; optionValue : UINT_PTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "RPCRT4.dll"
#cfunc global RpcBindingSetOption "RpcBindingSetOption" sptr, int, sptr
; res = RpcBindingSetOption(hBinding, option, optionValue)
; hBinding : void* -> "sptr"
; option : DWORD -> "int"
; optionValue : UINT_PTR -> "sptr"; RPC_STATUS RpcBindingSetOption(void* hBinding, DWORD option, UINT_PTR optionValue)
#uselib "RPCRT4.dll"
#cfunc global RpcBindingSetOption "RpcBindingSetOption" intptr, int, intptr
; res = RpcBindingSetOption(hBinding, option, optionValue)
; hBinding : void* -> "intptr"
; option : DWORD -> "int"
; optionValue : UINT_PTR -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
procRpcBindingSetOption = rpcrt4.NewProc("RpcBindingSetOption")
)
// hBinding (void*), option (DWORD), optionValue (UINT_PTR)
r1, _, err := procRpcBindingSetOption.Call(
uintptr(hBinding),
uintptr(option),
uintptr(optionValue),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // RPC_STATUSfunction RpcBindingSetOption(
hBinding: Pointer; // void*
option: DWORD; // DWORD
optionValue: NativeUInt // UINT_PTR
): Integer; stdcall;
external 'RPCRT4.dll' name 'RpcBindingSetOption';result := DllCall("RPCRT4\RpcBindingSetOption"
, "Ptr", hBinding ; void*
, "UInt", option ; DWORD
, "UPtr", optionValue ; UINT_PTR
, "Int") ; return: RPC_STATUS●RpcBindingSetOption(hBinding, option, optionValue) = DLL("RPCRT4.dll", "int RpcBindingSetOption(void*, dword, int)")
# 呼び出し: RpcBindingSetOption(hBinding, option, optionValue)
# hBinding : void* -> "void*"
# option : DWORD -> "dword"
# optionValue : UINT_PTR -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "rpcrt4" fn RpcBindingSetOption(
hBinding: ?*anyopaque, // void*
option: u32, // DWORD
optionValue: usize // UINT_PTR
) callconv(std.os.windows.WINAPI) i32;proc RpcBindingSetOption(
hBinding: pointer, # void*
option: uint32, # DWORD
optionValue: uint # UINT_PTR
): int32 {.importc: "RpcBindingSetOption", stdcall, dynlib: "RPCRT4.dll".}pragma(lib, "rpcrt4");
extern(Windows)
int RpcBindingSetOption(
void* hBinding, // void*
uint option, // DWORD
size_t optionValue // UINT_PTR
);ccall((:RpcBindingSetOption, "RPCRT4.dll"), stdcall, Int32,
(Ptr{Cvoid}, UInt32, Csize_t),
hBinding, option, optionValue)
# hBinding : void* -> Ptr{Cvoid}
# option : DWORD -> UInt32
# optionValue : UINT_PTR -> Csize_t
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t RpcBindingSetOption(
void* hBinding,
uint32_t option,
uintptr_t optionValue);
]]
local rpcrt4 = ffi.load("rpcrt4")
-- rpcrt4.RpcBindingSetOption(hBinding, option, optionValue)
-- hBinding : void*
-- option : DWORD
-- optionValue : UINT_PTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('RPCRT4.dll');
const RpcBindingSetOption = lib.func('__stdcall', 'RpcBindingSetOption', 'int32_t', ['void *', 'uint32_t', 'uintptr_t']);
// RpcBindingSetOption(hBinding, option, optionValue)
// hBinding : void* -> 'void *'
// option : DWORD -> 'uint32_t'
// optionValue : UINT_PTR -> 'uintptr_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("RPCRT4.dll", {
RpcBindingSetOption: { parameters: ["pointer", "u32", "usize"], result: "i32" },
});
// lib.symbols.RpcBindingSetOption(hBinding, option, optionValue)
// hBinding : void* -> "pointer"
// option : DWORD -> "u32"
// optionValue : UINT_PTR -> "usize"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t RpcBindingSetOption(
void* hBinding,
uint32_t option,
size_t optionValue);
C, "RPCRT4.dll");
// $ffi->RpcBindingSetOption(hBinding, option, optionValue);
// hBinding : void*
// option : DWORD
// optionValue : UINT_PTR
// 構造体/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);
int RpcBindingSetOption(
Pointer hBinding, // void*
int option, // DWORD
long optionValue // UINT_PTR
);
}@[Link("rpcrt4")]
lib LibRPCRT4
fun RpcBindingSetOption = RpcBindingSetOption(
hBinding : Void*, # void*
option : UInt32, # DWORD
optionValue : LibC::SizeT # UINT_PTR
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef RpcBindingSetOptionNative = Int32 Function(Pointer<Void>, Uint32, UintPtr);
typedef RpcBindingSetOptionDart = int Function(Pointer<Void>, int, int);
final RpcBindingSetOption = DynamicLibrary.open('RPCRT4.dll')
.lookupFunction<RpcBindingSetOptionNative, RpcBindingSetOptionDart>('RpcBindingSetOption');
// hBinding : void* -> Pointer<Void>
// option : DWORD -> Uint32
// optionValue : UINT_PTR -> UintPtr
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function RpcBindingSetOption(
hBinding: Pointer; // void*
option: DWORD; // DWORD
optionValue: NativeUInt // UINT_PTR
): Integer; stdcall;
external 'RPCRT4.dll' name 'RpcBindingSetOption';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RpcBindingSetOption"
c_RpcBindingSetOption :: Ptr () -> Word32 -> CUIntPtr -> IO Int32
-- hBinding : void* -> Ptr ()
-- option : DWORD -> Word32
-- optionValue : UINT_PTR -> CUIntPtr
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let rpcbindingsetoption =
foreign "RpcBindingSetOption"
((ptr void) @-> uint32_t @-> size_t @-> returning int32_t)
(* hBinding : void* -> (ptr void) *)
(* option : DWORD -> uint32_t *)
(* optionValue : UINT_PTR -> size_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library rpcrt4 (t "RPCRT4.dll"))
(cffi:use-foreign-library rpcrt4)
(cffi:defcfun ("RpcBindingSetOption" rpc-binding-set-option :convention :stdcall) :int32
(h-binding :pointer) ; void*
(option :uint32) ; DWORD
(option-value :uint64)) ; UINT_PTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RpcBindingSetOption = Win32::API::More->new('RPCRT4',
'int RpcBindingSetOption(LPVOID hBinding, DWORD option, WPARAM optionValue)');
# my $ret = $RpcBindingSetOption->Call($hBinding, $option, $optionValue);
# hBinding : void* -> LPVOID
# option : DWORD -> DWORD
# optionValue : UINT_PTR -> WPARAM
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型