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

BluetoothGATTAbortReliableWrite

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

シグネチャ

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

HRESULT BluetoothGATTAbortReliableWrite(
    HANDLE hDevice,
    ULONGLONG ReliableWriteContext,
    DWORD Flags
);

パラメーター

名前方向説明
hDeviceHANDLEin対象のBLEデバイスを表すハンドル。CreateFileで開いたデバイスハンドルを指定する。
ReliableWriteContextULONGLONGinBluetoothGATTBeginReliableWriteで取得した信頼性書き込みコンテキストを指定する。中止対象のトランザクションを識別する。
FlagsDWORDin動作を制御するフラグ。通常は予約値として0を指定する。

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT BluetoothGATTAbortReliableWrite(
    HANDLE hDevice,
    ULONGLONG ReliableWriteContext,
    DWORD Flags
);
[DllImport("BluetoothApis.dll", ExactSpelling = true)]
static extern int BluetoothGATTAbortReliableWrite(
    IntPtr hDevice,   // HANDLE
    ulong ReliableWriteContext,   // ULONGLONG
    uint Flags   // DWORD
);
<DllImport("BluetoothApis.dll", ExactSpelling:=True)>
Public Shared Function BluetoothGATTAbortReliableWrite(
    hDevice As IntPtr,   ' HANDLE
    ReliableWriteContext As ULong,   ' ULONGLONG
    Flags As UInteger   ' DWORD
) As Integer
End Function
' hDevice : HANDLE
' ReliableWriteContext : ULONGLONG
' Flags : DWORD
Declare PtrSafe Function BluetoothGATTAbortReliableWrite Lib "bluetoothapis" ( _
    ByVal hDevice As LongPtr, _
    ByVal 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

BluetoothGATTAbortReliableWrite = ctypes.windll.bluetoothapis.BluetoothGATTAbortReliableWrite
BluetoothGATTAbortReliableWrite.restype = ctypes.c_int
BluetoothGATTAbortReliableWrite.argtypes = [
    wintypes.HANDLE,  # hDevice : HANDLE
    ctypes.c_ulonglong,  # ReliableWriteContext : ULONGLONG
    wintypes.DWORD,  # Flags : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('BluetoothApis.dll')
BluetoothGATTAbortReliableWrite = Fiddle::Function.new(
  lib['BluetoothGATTAbortReliableWrite'],
  [
    Fiddle::TYPE_VOIDP,  # hDevice : HANDLE
    -Fiddle::TYPE_LONG_LONG,  # ReliableWriteContext : ULONGLONG
    -Fiddle::TYPE_INT,  # Flags : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "bluetoothapis")]
extern "system" {
    fn BluetoothGATTAbortReliableWrite(
        hDevice: *mut core::ffi::c_void,  // HANDLE
        ReliableWriteContext: u64,  // ULONGLONG
        Flags: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("BluetoothApis.dll")]
public static extern int BluetoothGATTAbortReliableWrite(IntPtr hDevice, ulong ReliableWriteContext, uint Flags);
"@
$api = Add-Type -MemberDefinition $sig -Name 'BluetoothApis_BluetoothGATTAbortReliableWrite' -Namespace Win32 -PassThru
# $api::BluetoothGATTAbortReliableWrite(hDevice, ReliableWriteContext, Flags)
#uselib "BluetoothApis.dll"
#func global BluetoothGATTAbortReliableWrite "BluetoothGATTAbortReliableWrite" sptr, sptr, sptr
; BluetoothGATTAbortReliableWrite hDevice, ReliableWriteContext, Flags   ; 戻り値は stat
; hDevice : HANDLE -> "sptr"
; ReliableWriteContext : ULONGLONG -> "sptr"
; Flags : DWORD -> "sptr"
; ※HSP3.7は int64 引数(64bit値渡し)に非対応です。
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "BluetoothApis.dll"
#cfunc global BluetoothGATTAbortReliableWrite "BluetoothGATTAbortReliableWrite" sptr, int64, int
; res = BluetoothGATTAbortReliableWrite(hDevice, ReliableWriteContext, Flags)
; hDevice : HANDLE -> "sptr"
; ReliableWriteContext : ULONGLONG -> "int64"
; Flags : DWORD -> "int"
; ※int64 引数の DLL 値渡しは x64 ランタイム(hsp3_64)のみ対応(x86 は未対応)。
; HRESULT BluetoothGATTAbortReliableWrite(HANDLE hDevice, ULONGLONG ReliableWriteContext, DWORD Flags)
#uselib "BluetoothApis.dll"
#cfunc global BluetoothGATTAbortReliableWrite "BluetoothGATTAbortReliableWrite" intptr, int64, int
; res = BluetoothGATTAbortReliableWrite(hDevice, ReliableWriteContext, Flags)
; hDevice : HANDLE -> "intptr"
; ReliableWriteContext : ULONGLONG -> "int64"
; Flags : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	bluetoothapis = windows.NewLazySystemDLL("BluetoothApis.dll")
	procBluetoothGATTAbortReliableWrite = bluetoothapis.NewProc("BluetoothGATTAbortReliableWrite")
)

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

extern "bluetoothapis" fn BluetoothGATTAbortReliableWrite(
    hDevice: ?*anyopaque, // HANDLE
    ReliableWriteContext: u64, // ULONGLONG
    Flags: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;
proc BluetoothGATTAbortReliableWrite(
    hDevice: pointer,  # HANDLE
    ReliableWriteContext: uint64,  # ULONGLONG
    Flags: uint32  # DWORD
): int32 {.importc: "BluetoothGATTAbortReliableWrite", stdcall, dynlib: "BluetoothApis.dll".}
pragma(lib, "bluetoothapis");
extern(Windows)
int BluetoothGATTAbortReliableWrite(
    void* hDevice,   // HANDLE
    ulong ReliableWriteContext,   // ULONGLONG
    uint Flags   // DWORD
);
ccall((:BluetoothGATTAbortReliableWrite, "BluetoothApis.dll"), stdcall, Int32,
      (Ptr{Cvoid}, UInt64, UInt32),
      hDevice, ReliableWriteContext, Flags)
# hDevice : HANDLE -> Ptr{Cvoid}
# ReliableWriteContext : ULONGLONG -> UInt64
# Flags : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t BluetoothGATTAbortReliableWrite(
    void* hDevice,
    uint64_t ReliableWriteContext,
    uint32_t Flags);
]]
local bluetoothapis = ffi.load("bluetoothapis")
-- bluetoothapis.BluetoothGATTAbortReliableWrite(hDevice, ReliableWriteContext, Flags)
-- hDevice : HANDLE
-- ReliableWriteContext : ULONGLONG
-- Flags : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('BluetoothApis.dll');
const BluetoothGATTAbortReliableWrite = lib.func('__stdcall', 'BluetoothGATTAbortReliableWrite', 'int32_t', ['void *', 'uint64_t', 'uint32_t']);
// BluetoothGATTAbortReliableWrite(hDevice, ReliableWriteContext, Flags)
// hDevice : HANDLE -> 'void *'
// ReliableWriteContext : ULONGLONG -> 'uint64_t'
// Flags : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("BluetoothApis.dll", {
  BluetoothGATTAbortReliableWrite: { parameters: ["pointer", "u64", "u32"], result: "i32" },
});
// lib.symbols.BluetoothGATTAbortReliableWrite(hDevice, ReliableWriteContext, Flags)
// hDevice : HANDLE -> "pointer"
// ReliableWriteContext : ULONGLONG -> "u64"
// Flags : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t BluetoothGATTAbortReliableWrite(
    void* hDevice,
    uint64_t ReliableWriteContext,
    uint32_t Flags);
C, "BluetoothApis.dll");
// $ffi->BluetoothGATTAbortReliableWrite(hDevice, ReliableWriteContext, Flags);
// hDevice : HANDLE
// ReliableWriteContext : ULONGLONG
// 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 BluetoothGATTAbortReliableWrite(
        Pointer hDevice,   // HANDLE
        long ReliableWriteContext,   // ULONGLONG
        int Flags   // DWORD
    );
}
@[Link("bluetoothapis")]
lib LibBluetoothApis
  fun BluetoothGATTAbortReliableWrite = BluetoothGATTAbortReliableWrite(
    hDevice : Void*,   # HANDLE
    ReliableWriteContext : UInt64,   # ULONGLONG
    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 BluetoothGATTAbortReliableWriteNative = Int32 Function(Pointer<Void>, Uint64, Uint32);
typedef BluetoothGATTAbortReliableWriteDart = int Function(Pointer<Void>, int, int);
final BluetoothGATTAbortReliableWrite = DynamicLibrary.open('BluetoothApis.dll')
    .lookupFunction<BluetoothGATTAbortReliableWriteNative, BluetoothGATTAbortReliableWriteDart>('BluetoothGATTAbortReliableWrite');
// hDevice : HANDLE -> Pointer<Void>
// ReliableWriteContext : ULONGLONG -> Uint64
// Flags : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function BluetoothGATTAbortReliableWrite(
  hDevice: THandle;   // HANDLE
  ReliableWriteContext: UInt64;   // ULONGLONG
  Flags: DWORD   // DWORD
): Integer; stdcall;
  external 'BluetoothApis.dll' name 'BluetoothGATTAbortReliableWrite';
import Foreign
import Foreign.C.Types
import Foreign.C.String

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

let bluetoothgattabortreliablewrite =
  foreign "BluetoothGATTAbortReliableWrite"
    ((ptr void) @-> uint64_t @-> uint32_t @-> returning int32_t)
(* hDevice : HANDLE -> (ptr void) *)
(* ReliableWriteContext : ULONGLONG -> 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 ("BluetoothGATTAbortReliableWrite" bluetooth-gattabort-reliable-write :convention :stdcall) :int32
  (h-device :pointer)   ; HANDLE
  (reliable-write-context :uint64)   ; ULONGLONG
  (flags :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $BluetoothGATTAbortReliableWrite = Win32::API::More->new('BluetoothApis',
    'int BluetoothGATTAbortReliableWrite(HANDLE hDevice, UINT64 ReliableWriteContext, DWORD Flags)');
# my $ret = $BluetoothGATTAbortReliableWrite->Call($hDevice, $ReliableWriteContext, $Flags);
# hDevice : HANDLE -> HANDLE
# ReliableWriteContext : ULONGLONG -> UINT64
# Flags : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。