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

BTH_HCI_EVENT_INFO

構造体
サイズx64: 16 バイト / x86: 16 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
bthAddressULONGLONG8+0+0対象リモートデバイスの48ビットBluetoothアドレスを保持する。
connectionTypeBYTE1+8+8接続の種類を示すコード。ACLやSCOなどのリンク種別を表す。
connectedBYTE1+9+9接続確立か切断かを示すブール値。0以外で接続中。

各言語での定義

#include <windows.h>

// BTH_HCI_EVENT_INFO  (x64 16 / x86 16 バイト)
typedef struct BTH_HCI_EVENT_INFO {
    ULONGLONG bthAddress;
    BYTE connectionType;
    BYTE connected;
} BTH_HCI_EVENT_INFO;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct BTH_HCI_EVENT_INFO
{
    public ulong bthAddress;
    public byte connectionType;
    public byte connected;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure BTH_HCI_EVENT_INFO
    Public bthAddress As ULong
    Public connectionType As Byte
    Public connected As Byte
End Structure
import ctypes
from ctypes import wintypes

class BTH_HCI_EVENT_INFO(ctypes.Structure):
    _fields_ = [
        ("bthAddress", ctypes.c_ulonglong),
        ("connectionType", ctypes.c_ubyte),
        ("connected", ctypes.c_ubyte),
    ]
#[repr(C)]
pub struct BTH_HCI_EVENT_INFO {
    pub bthAddress: u64,
    pub connectionType: u8,
    pub connected: u8,
}
import "golang.org/x/sys/windows"

type BTH_HCI_EVENT_INFO struct {
	bthAddress uint64
	connectionType byte
	connected byte
}
type
  BTH_HCI_EVENT_INFO = record
    bthAddress: UInt64;
    connectionType: Byte;
    connected: Byte;
  end;
const BTH_HCI_EVENT_INFO = extern struct {
    bthAddress: u64,
    connectionType: u8,
    connected: u8,
};
type
  BTH_HCI_EVENT_INFO {.bycopy.} = object
    bthAddress: uint64
    connectionType: uint8
    connected: uint8
struct BTH_HCI_EVENT_INFO
{
    ulong bthAddress;
    ubyte connectionType;
    ubyte connected;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; BTH_HCI_EVENT_INFO サイズ: 16 バイト(x64)
dim st, 4    ; 4byte整数×4(構造体サイズ 16 / 4 切り上げ)
; bthAddress : ULONGLONG (+0, 8byte)  qpoke st,0,値 / qpeek(st,0)  ※IronHSPのみ。3.7/3.8は lpoke st,0,下位 : lpoke st,4,上位
; connectionType : BYTE (+8, 1byte)  poke st,8,値  /  値 = peek(st,8)
; connected : BYTE (+9, 1byte)  poke st,9,値  /  値 = peek(st,9)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global BTH_HCI_EVENT_INFO
    #field int64 bthAddress
    #field byte connectionType
    #field byte connected
#endstruct

stdim st, BTH_HCI_EVENT_INFO        ; NSTRUCT 変数を確保
st->bthAddress = 100
mes "bthAddress=" + st->bthAddress