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

BluetoothGATTGetDescriptorValue

関数
GATTディスクリプタの値を読み取り取得する。
DLLBluetoothApis.dll呼出規約winapi対応OSwindows8.0

シグネチャ

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

HRESULT BluetoothGATTGetDescriptorValue(
    HANDLE hDevice,
    BTH_LE_GATT_DESCRIPTOR* Descriptor,
    DWORD DescriptorValueDataSize,
    BTH_LE_GATT_DESCRIPTOR_VALUE* DescriptorValue,   // optional
    WORD* DescriptorValueSizeRequired,   // optional
    DWORD Flags
);

パラメーター

名前方向説明
hDeviceHANDLEinディスクリプタ値を読み取る対象BLEデバイスのハンドル。
DescriptorBTH_LE_GATT_DESCRIPTOR*in値を読み取る対象ディスクリプタの構造体ポインタ。
DescriptorValueDataSizeDWORDinDescriptorValueバッファのバイトサイズ。サイズ照会時は0。
DescriptorValueBTH_LE_GATT_DESCRIPTOR_VALUE*outoptional読み取った値を受け取る構造体ポインタ。サイズ照会時はNULL。
DescriptorValueSizeRequiredWORD*outoptional必要なバッファサイズを受け取る出力ポインタ。
FlagsDWORDin読み取り動作を制御するフラグ。キャッシュ利用/強制読み取り等。

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

BluetoothGATTGetDescriptorValue = ctypes.windll.bluetoothapis.BluetoothGATTGetDescriptorValue
BluetoothGATTGetDescriptorValue.restype = ctypes.c_int
BluetoothGATTGetDescriptorValue.argtypes = [
    wintypes.HANDLE,  # hDevice : HANDLE
    ctypes.c_void_p,  # Descriptor : BTH_LE_GATT_DESCRIPTOR*
    wintypes.DWORD,  # DescriptorValueDataSize : DWORD
    ctypes.c_void_p,  # DescriptorValue : BTH_LE_GATT_DESCRIPTOR_VALUE* optional, out
    ctypes.POINTER(ctypes.c_ushort),  # DescriptorValueSizeRequired : WORD* optional, out
    wintypes.DWORD,  # Flags : DWORD
]
require 'fiddle'
require 'fiddle/import'

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

var (
	bluetoothapis = windows.NewLazySystemDLL("BluetoothApis.dll")
	procBluetoothGATTGetDescriptorValue = bluetoothapis.NewProc("BluetoothGATTGetDescriptorValue")
)

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

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

foreign import stdcall safe "BluetoothGATTGetDescriptorValue"
  c_BluetoothGATTGetDescriptorValue :: Ptr () -> Ptr () -> Word32 -> Ptr () -> Ptr Word16 -> Word32 -> IO Int32
-- hDevice : HANDLE -> Ptr ()
-- Descriptor : BTH_LE_GATT_DESCRIPTOR* -> Ptr ()
-- DescriptorValueDataSize : DWORD -> Word32
-- DescriptorValue : BTH_LE_GATT_DESCRIPTOR_VALUE* optional, out -> Ptr ()
-- DescriptorValueSizeRequired : WORD* optional, out -> Ptr Word16
-- Flags : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let bluetoothgattgetdescriptorvalue =
  foreign "BluetoothGATTGetDescriptorValue"
    ((ptr void) @-> (ptr void) @-> uint32_t @-> (ptr void) @-> (ptr uint16_t) @-> uint32_t @-> returning int32_t)
(* hDevice : HANDLE -> (ptr void) *)
(* Descriptor : BTH_LE_GATT_DESCRIPTOR* -> (ptr void) *)
(* DescriptorValueDataSize : DWORD -> uint32_t *)
(* DescriptorValue : BTH_LE_GATT_DESCRIPTOR_VALUE* optional, out -> (ptr void) *)
(* DescriptorValueSizeRequired : WORD* optional, out -> (ptr uint16_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 ("BluetoothGATTGetDescriptorValue" bluetooth-gattget-descriptor-value :convention :stdcall) :int32
  (h-device :pointer)   ; HANDLE
  (descriptor :pointer)   ; BTH_LE_GATT_DESCRIPTOR*
  (descriptor-value-data-size :uint32)   ; DWORD
  (descriptor-value :pointer)   ; BTH_LE_GATT_DESCRIPTOR_VALUE* optional, out
  (descriptor-value-size-required :pointer)   ; WORD* optional, out
  (flags :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $BluetoothGATTGetDescriptorValue = Win32::API::More->new('BluetoothApis',
    'int BluetoothGATTGetDescriptorValue(HANDLE hDevice, LPVOID Descriptor, DWORD DescriptorValueDataSize, LPVOID DescriptorValue, LPVOID DescriptorValueSizeRequired, DWORD Flags)');
# my $ret = $BluetoothGATTGetDescriptorValue->Call($hDevice, $Descriptor, $DescriptorValueDataSize, $DescriptorValue, $DescriptorValueSizeRequired, $Flags);
# hDevice : HANDLE -> HANDLE
# Descriptor : BTH_LE_GATT_DESCRIPTOR* -> LPVOID
# DescriptorValueDataSize : DWORD -> DWORD
# DescriptorValue : BTH_LE_GATT_DESCRIPTOR_VALUE* optional, out -> LPVOID
# DescriptorValueSizeRequired : WORD* optional, out -> LPVOID
# Flags : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型