ホーム › Devices.Bluetooth › BTH_QUERY_SERVICE
BTH_QUERY_SERVICE
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 |
|---|---|---|---|---|---|
| type | DWORD | 4 | +0 | +0 | クエリ種別を示す。SDPサービス検索の種類を表す。 |
| serviceHandle | DWORD | 4 | +4 | +4 | 対象とするSDPサービスレコードのハンドル。 |
| uuids | SdpQueryUuid | 240 | +8 | +8 | 検索対象サービスのUUIDを保持するSdpQueryUuid配列。 |
| numRange | DWORD | 4 | +248 | +248 | pRange配列に含まれる属性範囲の個数を示す。 |
| pRange | SdpAttributeRange | 4 | +252 | +252 | 取得対象の属性ID範囲を示すSdpAttributeRange配列。 |
各言語での定義
#include <windows.h>
// SdpQueryUuidUnion (x64 16 / x86 16 バイト)
typedef struct SdpQueryUuidUnion {
GUID uuid128;
DWORD uuid32;
WORD uuid16;
} SdpQueryUuidUnion;
// SdpQueryUuid (x64 20 / x86 20 バイト)
typedef struct SdpQueryUuid {
SdpQueryUuidUnion u;
WORD uuidType;
} SdpQueryUuid;
// SdpAttributeRange (x64 4 / x86 4 バイト)
typedef struct SdpAttributeRange {
WORD minAttribute;
WORD maxAttribute;
} SdpAttributeRange;
// BTH_QUERY_SERVICE (x64 256 / x86 256 バイト)
#pragma pack(push, 1)
typedef struct BTH_QUERY_SERVICE {
DWORD type;
DWORD serviceHandle;
SdpQueryUuid uuids[12];
DWORD numRange;
SdpAttributeRange pRange[1];
} BTH_QUERY_SERVICE;
#pragma pack(pop)using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SdpQueryUuidUnion
{
public Guid uuid128;
public uint uuid32;
public ushort uuid16;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SdpQueryUuid
{
public SdpQueryUuidUnion u;
public ushort uuidType;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SdpAttributeRange
{
public ushort minAttribute;
public ushort maxAttribute;
}
[StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)]
public struct BTH_QUERY_SERVICE
{
public uint type;
public uint serviceHandle;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)] public SdpQueryUuid[] uuids;
public uint numRange;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public SdpAttributeRange[] pRange;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SdpQueryUuidUnion
Public uuid128 As Guid
Public uuid32 As UInteger
Public uuid16 As UShort
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SdpQueryUuid
Public u As SdpQueryUuidUnion
Public uuidType As UShort
End Structure
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SdpAttributeRange
Public minAttribute As UShort
Public maxAttribute As UShort
End Structure
<StructLayout(LayoutKind.Sequential, Pack:=1, CharSet:=CharSet.Unicode)>
Public Structure BTH_QUERY_SERVICE
Public type As UInteger
Public serviceHandle As UInteger
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=12)> Public uuids() As SdpQueryUuid
Public numRange As UInteger
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=1)> Public pRange() As SdpAttributeRange
End Structureimport ctypes
from ctypes import wintypes
class SdpQueryUuidUnion(ctypes.Structure):
_fields_ = [
("uuid128", GUID),
("uuid32", wintypes.DWORD),
("uuid16", ctypes.c_ushort),
]
class SdpQueryUuid(ctypes.Structure):
_fields_ = [
("u", SdpQueryUuidUnion),
("uuidType", ctypes.c_ushort),
]
class SdpAttributeRange(ctypes.Structure):
_fields_ = [
("minAttribute", ctypes.c_ushort),
("maxAttribute", ctypes.c_ushort),
]
class BTH_QUERY_SERVICE(ctypes.Structure):
_pack_ = 1
_fields_ = [
("type", wintypes.DWORD),
("serviceHandle", wintypes.DWORD),
("uuids", SdpQueryUuid * 12),
("numRange", wintypes.DWORD),
("pRange", SdpAttributeRange * 1),
]#[repr(C)]
pub struct SdpQueryUuidUnion {
pub uuid128: GUID,
pub uuid32: u32,
pub uuid16: u16,
}
#[repr(C)]
pub struct SdpQueryUuid {
pub u: SdpQueryUuidUnion,
pub uuidType: u16,
}
#[repr(C)]
pub struct SdpAttributeRange {
pub minAttribute: u16,
pub maxAttribute: u16,
}
#[repr(C, packed(1))]
pub struct BTH_QUERY_SERVICE {
pub type: u32,
pub serviceHandle: u32,
pub uuids: [SdpQueryUuid; 12],
pub numRange: u32,
pub pRange: [SdpAttributeRange; 1],
}import "golang.org/x/sys/windows"
type SdpQueryUuidUnion struct {
uuid128 windows.GUID
uuid32 uint32
uuid16 uint16
}
type SdpQueryUuid struct {
u SdpQueryUuidUnion
uuidType uint16
}
type SdpAttributeRange struct {
minAttribute uint16
maxAttribute uint16
}
type BTH_QUERY_SERVICE struct {
type uint32
serviceHandle uint32
uuids [12]SdpQueryUuid
numRange uint32
pRange [1]SdpAttributeRange
}type
SdpQueryUuidUnion = record
uuid128: TGUID;
uuid32: DWORD;
uuid16: Word;
end;
SdpQueryUuid = record
u: SdpQueryUuidUnion;
uuidType: Word;
end;
SdpAttributeRange = record
minAttribute: Word;
maxAttribute: Word;
end;
BTH_QUERY_SERVICE = packed record
type: DWORD;
serviceHandle: DWORD;
uuids: array[0..11] of SdpQueryUuid;
numRange: DWORD;
pRange: array[0..0] of SdpAttributeRange;
end;const SdpQueryUuidUnion = extern struct {
uuid128: GUID,
uuid32: u32,
uuid16: u16,
};
const SdpQueryUuid = extern struct {
u: SdpQueryUuidUnion,
uuidType: u16,
};
const SdpAttributeRange = extern struct {
minAttribute: u16,
maxAttribute: u16,
};
const BTH_QUERY_SERVICE = extern struct {
type: u32,
serviceHandle: u32,
uuids: [12]SdpQueryUuid,
numRange: u32,
pRange: [1]SdpAttributeRange,
};type
SdpQueryUuidUnion {.bycopy.} = object
uuid128: GUID
uuid32: uint32
uuid16: uint16
SdpQueryUuid {.bycopy.} = object
u: SdpQueryUuidUnion
uuidType: uint16
SdpAttributeRange {.bycopy.} = object
minAttribute: uint16
maxAttribute: uint16
BTH_QUERY_SERVICE {.packed.} = object
type: uint32
serviceHandle: uint32
uuids: array[12, SdpQueryUuid]
numRange: uint32
pRange: array[1, SdpAttributeRange]struct SdpQueryUuidUnion
{
GUID uuid128;
uint uuid32;
ushort uuid16;
}
struct SdpQueryUuid
{
SdpQueryUuidUnion u;
ushort uuidType;
}
struct SdpAttributeRange
{
ushort minAttribute;
ushort maxAttribute;
}
align(1)
struct BTH_QUERY_SERVICE
{
uint type;
uint serviceHandle;
SdpQueryUuid[12] uuids;
uint numRange;
SdpAttributeRange[1] pRange;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; BTH_QUERY_SERVICE サイズ: 256 バイト(x64)
dim st, 64 ; 4byte整数×64(構造体サイズ 256 / 4 切り上げ)
; type : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; serviceHandle : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; uuids : SdpQueryUuid (+8, 240byte) varptr(st)+8 を基点に操作(240byte:入れ子/配列)
; numRange : DWORD (+248, 4byte) st.62 = 値 / 値 = st.62 (lpoke/lpeek も可)
; pRange : SdpAttributeRange (+252, 4byte) varptr(st)+252 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global SdpQueryUuid
#field byte u 16
#field short uuidType
#endstruct
#defstruct global SdpAttributeRange
#field short minAttribute
#field short maxAttribute
#endstruct
#defstruct global BTH_QUERY_SERVICE, pack=1
#field int type
#field int serviceHandle
#field SdpQueryUuid uuids 12
#field int numRange
#field SdpAttributeRange pRange 1
#endstruct
stdim st, BTH_QUERY_SERVICE ; NSTRUCT 変数を確保
st->type = 100
mes "type=" + st->type