ホーム › Devices.Bluetooth › BTH_DEVICE_INFO
BTH_DEVICE_INFO
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| flags | DWORD | 4 | +0 | +0 | 有効なフィールドを示すビットフラグ。名前やデバイスクラスの有効性を表す。 |
| address | ULONGLONG | 8 | +8 | +8 | リモートデバイスの48ビットBluetoothアドレスを保持する64ビット値。 |
| classOfDevice | DWORD | 4 | +16 | +16 | デバイスの種類を示すClass of Device値。機器カテゴリやサービス種別を含む。 |
| name | CHAR | 248 | +20 | +20 | デバイスのフレンドリ名を保持するナル終端文字配列。 |
各言語での定義
#include <windows.h>
// BTH_DEVICE_INFO (x64 272 / x86 272 バイト)
typedef struct BTH_DEVICE_INFO {
DWORD flags;
ULONGLONG address;
DWORD classOfDevice;
CHAR name[248];
} BTH_DEVICE_INFO;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct BTH_DEVICE_INFO
{
public uint flags;
public ulong address;
public uint classOfDevice;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 248)] public sbyte[] name;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure BTH_DEVICE_INFO
Public flags As UInteger
Public address As ULong
Public classOfDevice As UInteger
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=248)> Public name() As SByte
End Structureimport ctypes
from ctypes import wintypes
class BTH_DEVICE_INFO(ctypes.Structure):
_fields_ = [
("flags", wintypes.DWORD),
("address", ctypes.c_ulonglong),
("classOfDevice", wintypes.DWORD),
("name", ctypes.c_byte * 248),
]#[repr(C)]
pub struct BTH_DEVICE_INFO {
pub flags: u32,
pub address: u64,
pub classOfDevice: u32,
pub name: [i8; 248],
}import "golang.org/x/sys/windows"
type BTH_DEVICE_INFO struct {
flags uint32
address uint64
classOfDevice uint32
name [248]int8
}type
BTH_DEVICE_INFO = record
flags: DWORD;
address: UInt64;
classOfDevice: DWORD;
name: array[0..247] of Shortint;
end;const BTH_DEVICE_INFO = extern struct {
flags: u32,
address: u64,
classOfDevice: u32,
name: [248]i8,
};type
BTH_DEVICE_INFO {.bycopy.} = object
flags: uint32
address: uint64
classOfDevice: uint32
name: array[248, int8]struct BTH_DEVICE_INFO
{
uint flags;
ulong address;
uint classOfDevice;
byte[248] name;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; BTH_DEVICE_INFO サイズ: 272 バイト(x64)
dim st, 68 ; 4byte整数×68(構造体サイズ 272 / 4 切り上げ)
; flags : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; address : ULONGLONG (+8, 8byte) qpoke st,8,値 / qpeek(st,8) ※IronHSPのみ。3.7/3.8は lpoke st,8,下位 : lpoke st,12,上位
; classOfDevice : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; name : CHAR (+20, 248byte) varptr(st)+20 を基点に操作(248byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global BTH_DEVICE_INFO
#field int flags
#field int64 address
#field int classOfDevice
#field byte name 248
#endstruct
stdim st, BTH_DEVICE_INFO ; NSTRUCT 変数を確保
st->flags = 100
mes "flags=" + st->flags