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

BluetoothGATTSetDescriptorValue

関数
GATTディスクリプタに値を書き込む。
DLLBluetoothApis.dll呼出規約winapi対応OSwindows8.0

シグネチャ

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

HRESULT BluetoothGATTSetDescriptorValue(
    HANDLE hDevice,
    BTH_LE_GATT_DESCRIPTOR* Descriptor,
    BTH_LE_GATT_DESCRIPTOR_VALUE* DescriptorValue,
    DWORD Flags
);

パラメーター

名前方向
hDeviceHANDLEin
DescriptorBTH_LE_GATT_DESCRIPTOR*in
DescriptorValueBTH_LE_GATT_DESCRIPTOR_VALUE*in
FlagsDWORDin

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

BluetoothGATTSetDescriptorValue = ctypes.windll.bluetoothapis.BluetoothGATTSetDescriptorValue
BluetoothGATTSetDescriptorValue.restype = ctypes.c_int
BluetoothGATTSetDescriptorValue.argtypes = [
    wintypes.HANDLE,  # hDevice : HANDLE
    ctypes.c_void_p,  # Descriptor : BTH_LE_GATT_DESCRIPTOR*
    ctypes.c_void_p,  # DescriptorValue : BTH_LE_GATT_DESCRIPTOR_VALUE*
    wintypes.DWORD,  # Flags : DWORD
]
require 'fiddle'
require 'fiddle/import'

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

var (
	bluetoothapis = windows.NewLazySystemDLL("BluetoothApis.dll")
	procBluetoothGATTSetDescriptorValue = bluetoothapis.NewProc("BluetoothGATTSetDescriptorValue")
)

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