Win32 API 日本語リファレンス
ホームDevices.Bluetooth › BluetoothGATTBeginReliableWrite

BluetoothGATTBeginReliableWrite

関数
GATTの信頼性書き込みトランザクションを開始する。
DLLBluetoothApis.dll呼出規約winapi対応OSwindows8.0

シグネチャ

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

HRESULT BluetoothGATTBeginReliableWrite(
    HANDLE hDevice,
    ULONGLONG* ReliableWriteContext,
    DWORD Flags
);

パラメーター

名前方向説明
hDeviceHANDLEin信頼性書き込みトランザクションを開始する対象BLEデバイスのハンドル。
ReliableWriteContextULONGLONG*out開始したトランザクションのコンテキストを受け取る出力ポインタ。
FlagsDWORDin操作を制御するフラグ。BLUETOOTH_GATT_FLAG_NONE等。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT BluetoothGATTBeginReliableWrite(
    HANDLE hDevice,
    ULONGLONG* ReliableWriteContext,
    DWORD Flags
);
[DllImport("BluetoothApis.dll", ExactSpelling = true)]
static extern int BluetoothGATTBeginReliableWrite(
    IntPtr hDevice,   // HANDLE
    out ulong ReliableWriteContext,   // ULONGLONG* out
    uint Flags   // DWORD
);
<DllImport("BluetoothApis.dll", ExactSpelling:=True)>
Public Shared Function BluetoothGATTBeginReliableWrite(
    hDevice As IntPtr,   ' HANDLE
    <Out> ByRef ReliableWriteContext As ULong,   ' ULONGLONG* out
    Flags As UInteger   ' DWORD
) As Integer
End Function
' hDevice : HANDLE
' ReliableWriteContext : ULONGLONG* out
' Flags : DWORD
Declare PtrSafe Function BluetoothGATTBeginReliableWrite Lib "bluetoothapis" ( _
    ByVal hDevice As LongPtr, _
    ByRef ReliableWriteContext As LongLong, _
    ByVal Flags As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

BluetoothGATTBeginReliableWrite = ctypes.windll.bluetoothapis.BluetoothGATTBeginReliableWrite
BluetoothGATTBeginReliableWrite.restype = ctypes.c_int
BluetoothGATTBeginReliableWrite.argtypes = [
    wintypes.HANDLE,  # hDevice : HANDLE
    ctypes.POINTER(ctypes.c_ulonglong),  # ReliableWriteContext : ULONGLONG* out
    wintypes.DWORD,  # Flags : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('BluetoothApis.dll')
BluetoothGATTBeginReliableWrite = Fiddle::Function.new(
  lib['BluetoothGATTBeginReliableWrite'],
  [
    Fiddle::TYPE_VOIDP,  # hDevice : HANDLE
    Fiddle::TYPE_VOIDP,  # ReliableWriteContext : ULONGLONG* out
    -Fiddle::TYPE_INT,  # Flags : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "bluetoothapis")]
extern "system" {
    fn BluetoothGATTBeginReliableWrite(
        hDevice: *mut core::ffi::c_void,  // HANDLE
        ReliableWriteContext: *mut u64,  // ULONGLONG* out
        Flags: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("BluetoothApis.dll")]
public static extern int BluetoothGATTBeginReliableWrite(IntPtr hDevice, out ulong ReliableWriteContext, uint Flags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'BluetoothApis_BluetoothGATTBeginReliableWrite' -Namespace Win32 -PassThru
# $api::BluetoothGATTBeginReliableWrite(hDevice, ReliableWriteContext, Flags)
#uselib "BluetoothApis.dll"
#func global BluetoothGATTBeginReliableWrite "BluetoothGATTBeginReliableWrite" sptr, sptr, sptr
; BluetoothGATTBeginReliableWrite hDevice, varptr(ReliableWriteContext), Flags   ; 戻り値は stat
; hDevice : HANDLE -> "sptr"
; ReliableWriteContext : ULONGLONG* out -> "sptr"
; Flags : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "BluetoothApis.dll"
#cfunc global BluetoothGATTBeginReliableWrite "BluetoothGATTBeginReliableWrite" sptr, var, int
; res = BluetoothGATTBeginReliableWrite(hDevice, ReliableWriteContext, Flags)
; hDevice : HANDLE -> "sptr"
; ReliableWriteContext : ULONGLONG* out -> "var"
; Flags : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT BluetoothGATTBeginReliableWrite(HANDLE hDevice, ULONGLONG* ReliableWriteContext, DWORD Flags)
#uselib "BluetoothApis.dll"
#cfunc global BluetoothGATTBeginReliableWrite "BluetoothGATTBeginReliableWrite" intptr, var, int
; res = BluetoothGATTBeginReliableWrite(hDevice, ReliableWriteContext, Flags)
; hDevice : HANDLE -> "intptr"
; ReliableWriteContext : ULONGLONG* out -> "var"
; Flags : DWORD -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	bluetoothapis = windows.NewLazySystemDLL("BluetoothApis.dll")
	procBluetoothGATTBeginReliableWrite = bluetoothapis.NewProc("BluetoothGATTBeginReliableWrite")
)

// hDevice (HANDLE), ReliableWriteContext (ULONGLONG* out), Flags (DWORD)
r1, _, err := procBluetoothGATTBeginReliableWrite.Call(
	uintptr(hDevice),
	uintptr(ReliableWriteContext),
	uintptr(Flags),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function BluetoothGATTBeginReliableWrite(
  hDevice: THandle;   // HANDLE
  ReliableWriteContext: Pointer;   // ULONGLONG* out
  Flags: DWORD   // DWORD
): Integer; stdcall;
  external 'BluetoothApis.dll' name 'BluetoothGATTBeginReliableWrite';
result := DllCall("BluetoothApis\BluetoothGATTBeginReliableWrite"
    , "Ptr", hDevice   ; HANDLE
    , "Ptr", ReliableWriteContext   ; ULONGLONG* out
    , "UInt", Flags   ; DWORD
    , "Int")   ; return: HRESULT
●BluetoothGATTBeginReliableWrite(hDevice, ReliableWriteContext, Flags) = DLL("BluetoothApis.dll", "int BluetoothGATTBeginReliableWrite(void*, void*, dword)")
# 呼び出し: BluetoothGATTBeginReliableWrite(hDevice, ReliableWriteContext, Flags)
# hDevice : HANDLE -> "void*"
# ReliableWriteContext : ULONGLONG* out -> "void*"
# Flags : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "bluetoothapis" fn BluetoothGATTBeginReliableWrite(
    hDevice: ?*anyopaque, // HANDLE
    ReliableWriteContext: [*c]u64, // ULONGLONG* out
    Flags: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;
proc BluetoothGATTBeginReliableWrite(
    hDevice: pointer,  # HANDLE
    ReliableWriteContext: ptr uint64,  # ULONGLONG* out
    Flags: uint32  # DWORD
): int32 {.importc: "BluetoothGATTBeginReliableWrite", stdcall, dynlib: "BluetoothApis.dll".}
pragma(lib, "bluetoothapis");
extern(Windows)
int BluetoothGATTBeginReliableWrite(
    void* hDevice,   // HANDLE
    ulong* ReliableWriteContext,   // ULONGLONG* out
    uint Flags   // DWORD
);
ccall((:BluetoothGATTBeginReliableWrite, "BluetoothApis.dll"), stdcall, Int32,
      (Ptr{Cvoid}, Ptr{UInt64}, UInt32),
      hDevice, ReliableWriteContext, Flags)
# hDevice : HANDLE -> Ptr{Cvoid}
# ReliableWriteContext : ULONGLONG* out -> Ptr{UInt64}
# Flags : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t BluetoothGATTBeginReliableWrite(
    void* hDevice,
    uint64_t* ReliableWriteContext,
    uint32_t Flags);
]]
local bluetoothapis = ffi.load("bluetoothapis")
-- bluetoothapis.BluetoothGATTBeginReliableWrite(hDevice, ReliableWriteContext, Flags)
-- hDevice : HANDLE
-- ReliableWriteContext : ULONGLONG* out
-- Flags : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('BluetoothApis.dll');
const BluetoothGATTBeginReliableWrite = lib.func('__stdcall', 'BluetoothGATTBeginReliableWrite', 'int32_t', ['void *', 'uint64_t *', 'uint32_t']);
// BluetoothGATTBeginReliableWrite(hDevice, ReliableWriteContext, Flags)
// hDevice : HANDLE -> 'void *'
// ReliableWriteContext : ULONGLONG* out -> 'uint64_t *'
// Flags : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("BluetoothApis.dll", {
  BluetoothGATTBeginReliableWrite: { parameters: ["pointer", "pointer", "u32"], result: "i32" },
});
// lib.symbols.BluetoothGATTBeginReliableWrite(hDevice, ReliableWriteContext, Flags)
// hDevice : HANDLE -> "pointer"
// ReliableWriteContext : ULONGLONG* out -> "pointer"
// Flags : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t BluetoothGATTBeginReliableWrite(
    void* hDevice,
    uint64_t* ReliableWriteContext,
    uint32_t Flags);
C, "BluetoothApis.dll");
// $ffi->BluetoothGATTBeginReliableWrite(hDevice, ReliableWriteContext, Flags);
// hDevice : HANDLE
// ReliableWriteContext : ULONGLONG* out
// Flags : DWORD
// 構造体/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 Bluetoothapis extends StdCallLibrary {
    Bluetoothapis INSTANCE = Native.load("bluetoothapis", Bluetoothapis.class);
    int BluetoothGATTBeginReliableWrite(
        Pointer hDevice,   // HANDLE
        LongByReference ReliableWriteContext,   // ULONGLONG* out
        int Flags   // DWORD
    );
}
@[Link("bluetoothapis")]
lib LibBluetoothApis
  fun BluetoothGATTBeginReliableWrite = BluetoothGATTBeginReliableWrite(
    hDevice : Void*,   # HANDLE
    ReliableWriteContext : UInt64*,   # ULONGLONG* out
    Flags : UInt32   # DWORD
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef BluetoothGATTBeginReliableWriteNative = Int32 Function(Pointer<Void>, Pointer<Uint64>, Uint32);
typedef BluetoothGATTBeginReliableWriteDart = int Function(Pointer<Void>, Pointer<Uint64>, int);
final BluetoothGATTBeginReliableWrite = DynamicLibrary.open('BluetoothApis.dll')
    .lookupFunction<BluetoothGATTBeginReliableWriteNative, BluetoothGATTBeginReliableWriteDart>('BluetoothGATTBeginReliableWrite');
// hDevice : HANDLE -> Pointer<Void>
// ReliableWriteContext : ULONGLONG* out -> Pointer<Uint64>
// Flags : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function BluetoothGATTBeginReliableWrite(
  hDevice: THandle;   // HANDLE
  ReliableWriteContext: Pointer;   // ULONGLONG* out
  Flags: DWORD   // DWORD
): Integer; stdcall;
  external 'BluetoothApis.dll' name 'BluetoothGATTBeginReliableWrite';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "BluetoothGATTBeginReliableWrite"
  c_BluetoothGATTBeginReliableWrite :: Ptr () -> Ptr Word64 -> Word32 -> IO Int32
-- hDevice : HANDLE -> Ptr ()
-- ReliableWriteContext : ULONGLONG* out -> Ptr Word64
-- Flags : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let bluetoothgattbeginreliablewrite =
  foreign "BluetoothGATTBeginReliableWrite"
    ((ptr void) @-> (ptr uint64_t) @-> uint32_t @-> returning int32_t)
(* hDevice : HANDLE -> (ptr void) *)
(* ReliableWriteContext : ULONGLONG* out -> (ptr uint64_t) *)
(* Flags : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library bluetoothapis (t "BluetoothApis.dll"))
(cffi:use-foreign-library bluetoothapis)

(cffi:defcfun ("BluetoothGATTBeginReliableWrite" bluetooth-gattbegin-reliable-write :convention :stdcall) :int32
  (h-device :pointer)   ; HANDLE
  (reliable-write-context :pointer)   ; ULONGLONG* out
  (flags :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $BluetoothGATTBeginReliableWrite = Win32::API::More->new('BluetoothApis',
    'int BluetoothGATTBeginReliableWrite(HANDLE hDevice, LPVOID ReliableWriteContext, DWORD Flags)');
# my $ret = $BluetoothGATTBeginReliableWrite->Call($hDevice, $ReliableWriteContext, $Flags);
# hDevice : HANDLE -> HANDLE
# ReliableWriteContext : ULONGLONG* out -> LPVOID
# Flags : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。