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

BTH_L2CAP_EVENT_INFO

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

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

フィールド

フィールドサイズx64x86説明
bthAddressULONGLONG8+0+0対象リモートデバイスの48ビットBluetoothアドレスを保持する。
psmWORD2+8+8L2CAPのプロトコル・サービス多重化番号(PSM)を示す16ビット値。
connectedBYTE1+10+10接続が確立されたか切断されたかを示すブール値。0以外で接続。
initiatedBYTE1+11+11接続をローカル側が開始したか否かを示すブール値。0以外で自発接続。

各言語での定義

#include <windows.h>

// BTH_L2CAP_EVENT_INFO  (x64 16 / x86 16 バイト)
typedef struct BTH_L2CAP_EVENT_INFO {
    ULONGLONG bthAddress;
    WORD psm;
    BYTE connected;
    BYTE initiated;
} BTH_L2CAP_EVENT_INFO;
using System;
using System.Runtime.InteropServices;

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

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

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

type BTH_L2CAP_EVENT_INFO struct {
	bthAddress uint64
	psm uint16
	connected byte
	initiated byte
}
type
  BTH_L2CAP_EVENT_INFO = record
    bthAddress: UInt64;
    psm: Word;
    connected: Byte;
    initiated: Byte;
  end;
const BTH_L2CAP_EVENT_INFO = extern struct {
    bthAddress: u64,
    psm: u16,
    connected: u8,
    initiated: u8,
};
type
  BTH_L2CAP_EVENT_INFO {.bycopy.} = object
    bthAddress: uint64
    psm: uint16
    connected: uint8
    initiated: uint8
struct BTH_L2CAP_EVENT_INFO
{
    ulong bthAddress;
    ushort psm;
    ubyte connected;
    ubyte initiated;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; BTH_L2CAP_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,上位
; psm : WORD (+8, 2byte)  wpoke st,8,値  /  値 = wpeek(st,8)
; connected : BYTE (+10, 1byte)  poke st,10,値  /  値 = peek(st,10)
; initiated : BYTE (+11, 1byte)  poke st,11,値  /  値 = peek(st,11)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global BTH_L2CAP_EVENT_INFO
    #field int64 bthAddress
    #field short psm
    #field byte connected
    #field byte initiated
#endstruct

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