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

BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS

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

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

フィールド

フィールドサイズx64x86説明
deviceInfoBLUETOOTH_DEVICE_INFO560+0+0認証要求元のリモートデバイス情報を保持するBLUETOOTH_DEVICE_INFO。
authenticationMethodBLUETOOTH_AUTHENTICATION_METHOD4+560+560使用される認証方式を示す列挙値。レガシーやSSPなどを表す。
ioCapabilityBLUETOOTH_IO_CAPABILITY4+564+564デバイスの入出力能力を示す列挙値。ペアリング方式の決定に用いる。
authenticationRequirementsBLUETOOTH_AUTHENTICATION_REQUIREMENTS4+568+568MITM保護要否などの認証要件を示す列挙値。
Anonymous_Anonymous_e__Union4+572+572認証方式に応じた数値比較値やパスキー等を格納する無名共用体。

共用体: _Anonymous_e__Union x64 4B / x86 4B

フィールドサイズx64x86
Numeric_ValueDWORD4+0+0
PasskeyDWORD4+0+0

各言語での定義

#include <windows.h>

// BLUETOOTH_ADDRESS  (x64 8 / x86 8 バイト)
typedef struct BLUETOOTH_ADDRESS {
    _Anonymous_e__Union Anonymous;
} BLUETOOTH_ADDRESS;

// SYSTEMTIME  (x64 16 / x86 16 バイト)
typedef struct SYSTEMTIME {
    WORD wYear;
    WORD wMonth;
    WORD wDayOfWeek;
    WORD wDay;
    WORD wHour;
    WORD wMinute;
    WORD wSecond;
    WORD wMilliseconds;
} SYSTEMTIME;

// BLUETOOTH_DEVICE_INFO  (x64 560 / x86 560 バイト)
typedef struct BLUETOOTH_DEVICE_INFO {
    DWORD dwSize;
    BLUETOOTH_ADDRESS Address;
    DWORD ulClassofDevice;
    BOOL fConnected;
    BOOL fRemembered;
    BOOL fAuthenticated;
    SYSTEMTIME stLastSeen;
    SYSTEMTIME stLastUsed;
    WCHAR szName[248];
} BLUETOOTH_DEVICE_INFO;

// BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS  (x64 576 / x86 576 バイト)
typedef struct BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS {
    BLUETOOTH_DEVICE_INFO deviceInfo;
    BLUETOOTH_AUTHENTICATION_METHOD authenticationMethod;
    BLUETOOTH_IO_CAPABILITY ioCapability;
    BLUETOOTH_AUTHENTICATION_REQUIREMENTS authenticationRequirements;
    _Anonymous_e__Union Anonymous;
} BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct BLUETOOTH_ADDRESS
{
    public _Anonymous_e__Union Anonymous;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SYSTEMTIME
{
    public ushort wYear;
    public ushort wMonth;
    public ushort wDayOfWeek;
    public ushort wDay;
    public ushort wHour;
    public ushort wMinute;
    public ushort wSecond;
    public ushort wMilliseconds;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct BLUETOOTH_DEVICE_INFO
{
    public uint dwSize;
    public BLUETOOTH_ADDRESS Address;
    public uint ulClassofDevice;
    [MarshalAs(UnmanagedType.Bool)] public bool fConnected;
    [MarshalAs(UnmanagedType.Bool)] public bool fRemembered;
    [MarshalAs(UnmanagedType.Bool)] public bool fAuthenticated;
    public SYSTEMTIME stLastSeen;
    public SYSTEMTIME stLastUsed;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 248)] public string szName;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS
{
    public BLUETOOTH_DEVICE_INFO deviceInfo;
    public int authenticationMethod;
    public int ioCapability;
    public int authenticationRequirements;
    public _Anonymous_e__Union Anonymous;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure BLUETOOTH_ADDRESS
    Public Anonymous As _Anonymous_e__Union
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SYSTEMTIME
    Public wYear As UShort
    Public wMonth As UShort
    Public wDayOfWeek As UShort
    Public wDay As UShort
    Public wHour As UShort
    Public wMinute As UShort
    Public wSecond As UShort
    Public wMilliseconds As UShort
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure BLUETOOTH_DEVICE_INFO
    Public dwSize As UInteger
    Public Address As BLUETOOTH_ADDRESS
    Public ulClassofDevice As UInteger
    <MarshalAs(UnmanagedType.Bool)> Public fConnected As Boolean
    <MarshalAs(UnmanagedType.Bool)> Public fRemembered As Boolean
    <MarshalAs(UnmanagedType.Bool)> Public fAuthenticated As Boolean
    Public stLastSeen As SYSTEMTIME
    Public stLastUsed As SYSTEMTIME
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=248)> Public szName As String
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS
    Public deviceInfo As BLUETOOTH_DEVICE_INFO
    Public authenticationMethod As Integer
    Public ioCapability As Integer
    Public authenticationRequirements As Integer
    Public Anonymous As _Anonymous_e__Union
End Structure
import ctypes
from ctypes import wintypes

class BLUETOOTH_ADDRESS(ctypes.Structure):
    _fields_ = [
        ("Anonymous", _Anonymous_e__Union),
    ]

class SYSTEMTIME(ctypes.Structure):
    _fields_ = [
        ("wYear", ctypes.c_ushort),
        ("wMonth", ctypes.c_ushort),
        ("wDayOfWeek", ctypes.c_ushort),
        ("wDay", ctypes.c_ushort),
        ("wHour", ctypes.c_ushort),
        ("wMinute", ctypes.c_ushort),
        ("wSecond", ctypes.c_ushort),
        ("wMilliseconds", ctypes.c_ushort),
    ]

class BLUETOOTH_DEVICE_INFO(ctypes.Structure):
    _fields_ = [
        ("dwSize", wintypes.DWORD),
        ("Address", BLUETOOTH_ADDRESS),
        ("ulClassofDevice", wintypes.DWORD),
        ("fConnected", wintypes.BOOL),
        ("fRemembered", wintypes.BOOL),
        ("fAuthenticated", wintypes.BOOL),
        ("stLastSeen", SYSTEMTIME),
        ("stLastUsed", SYSTEMTIME),
        ("szName", ctypes.c_wchar * 248),
    ]

class BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS(ctypes.Structure):
    _fields_ = [
        ("deviceInfo", BLUETOOTH_DEVICE_INFO),
        ("authenticationMethod", ctypes.c_int),
        ("ioCapability", ctypes.c_int),
        ("authenticationRequirements", ctypes.c_int),
        ("Anonymous", _Anonymous_e__Union),
    ]
#[repr(C)]
pub struct BLUETOOTH_ADDRESS {
    pub Anonymous: _Anonymous_e__Union,
}

#[repr(C)]
pub struct SYSTEMTIME {
    pub wYear: u16,
    pub wMonth: u16,
    pub wDayOfWeek: u16,
    pub wDay: u16,
    pub wHour: u16,
    pub wMinute: u16,
    pub wSecond: u16,
    pub wMilliseconds: u16,
}

#[repr(C)]
pub struct BLUETOOTH_DEVICE_INFO {
    pub dwSize: u32,
    pub Address: BLUETOOTH_ADDRESS,
    pub ulClassofDevice: u32,
    pub fConnected: i32,
    pub fRemembered: i32,
    pub fAuthenticated: i32,
    pub stLastSeen: SYSTEMTIME,
    pub stLastUsed: SYSTEMTIME,
    pub szName: [u16; 248],
}

#[repr(C)]
pub struct BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS {
    pub deviceInfo: BLUETOOTH_DEVICE_INFO,
    pub authenticationMethod: i32,
    pub ioCapability: i32,
    pub authenticationRequirements: i32,
    pub Anonymous: _Anonymous_e__Union,
}
import "golang.org/x/sys/windows"

type BLUETOOTH_ADDRESS struct {
	Anonymous _Anonymous_e__Union
}

type SYSTEMTIME struct {
	wYear uint16
	wMonth uint16
	wDayOfWeek uint16
	wDay uint16
	wHour uint16
	wMinute uint16
	wSecond uint16
	wMilliseconds uint16
}

type BLUETOOTH_DEVICE_INFO struct {
	dwSize uint32
	Address BLUETOOTH_ADDRESS
	ulClassofDevice uint32
	fConnected int32
	fRemembered int32
	fAuthenticated int32
	stLastSeen SYSTEMTIME
	stLastUsed SYSTEMTIME
	szName [248]uint16
}

type BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS struct {
	deviceInfo BLUETOOTH_DEVICE_INFO
	authenticationMethod int32
	ioCapability int32
	authenticationRequirements int32
	Anonymous _Anonymous_e__Union
}
type
  BLUETOOTH_ADDRESS = record
    Anonymous: _Anonymous_e__Union;
  end;

  SYSTEMTIME = record
    wYear: Word;
    wMonth: Word;
    wDayOfWeek: Word;
    wDay: Word;
    wHour: Word;
    wMinute: Word;
    wSecond: Word;
    wMilliseconds: Word;
  end;

  BLUETOOTH_DEVICE_INFO = record
    dwSize: DWORD;
    Address: BLUETOOTH_ADDRESS;
    ulClassofDevice: DWORD;
    fConnected: BOOL;
    fRemembered: BOOL;
    fAuthenticated: BOOL;
    stLastSeen: SYSTEMTIME;
    stLastUsed: SYSTEMTIME;
    szName: array[0..247] of WideChar;
  end;

  BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS = record
    deviceInfo: BLUETOOTH_DEVICE_INFO;
    authenticationMethod: Integer;
    ioCapability: Integer;
    authenticationRequirements: Integer;
    Anonymous: _Anonymous_e__Union;
  end;
const BLUETOOTH_ADDRESS = extern struct {
    Anonymous: _Anonymous_e__Union,
};

const SYSTEMTIME = extern struct {
    wYear: u16,
    wMonth: u16,
    wDayOfWeek: u16,
    wDay: u16,
    wHour: u16,
    wMinute: u16,
    wSecond: u16,
    wMilliseconds: u16,
};

const BLUETOOTH_DEVICE_INFO = extern struct {
    dwSize: u32,
    Address: BLUETOOTH_ADDRESS,
    ulClassofDevice: u32,
    fConnected: i32,
    fRemembered: i32,
    fAuthenticated: i32,
    stLastSeen: SYSTEMTIME,
    stLastUsed: SYSTEMTIME,
    szName: [248]u16,
};

const BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS = extern struct {
    deviceInfo: BLUETOOTH_DEVICE_INFO,
    authenticationMethod: i32,
    ioCapability: i32,
    authenticationRequirements: i32,
    Anonymous: _Anonymous_e__Union,
};
type
  BLUETOOTH_ADDRESS {.bycopy.} = object
    Anonymous: _Anonymous_e__Union

  SYSTEMTIME {.bycopy.} = object
    wYear: uint16
    wMonth: uint16
    wDayOfWeek: uint16
    wDay: uint16
    wHour: uint16
    wMinute: uint16
    wSecond: uint16
    wMilliseconds: uint16

  BLUETOOTH_DEVICE_INFO {.bycopy.} = object
    dwSize: uint32
    Address: BLUETOOTH_ADDRESS
    ulClassofDevice: uint32
    fConnected: int32
    fRemembered: int32
    fAuthenticated: int32
    stLastSeen: SYSTEMTIME
    stLastUsed: SYSTEMTIME
    szName: array[248, uint16]

  BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS {.bycopy.} = object
    deviceInfo: BLUETOOTH_DEVICE_INFO
    authenticationMethod: int32
    ioCapability: int32
    authenticationRequirements: int32
    Anonymous: _Anonymous_e__Union
struct BLUETOOTH_ADDRESS
{
    _Anonymous_e__Union Anonymous;
}

struct SYSTEMTIME
{
    ushort wYear;
    ushort wMonth;
    ushort wDayOfWeek;
    ushort wDay;
    ushort wHour;
    ushort wMinute;
    ushort wSecond;
    ushort wMilliseconds;
}

struct BLUETOOTH_DEVICE_INFO
{
    uint dwSize;
    BLUETOOTH_ADDRESS Address;
    uint ulClassofDevice;
    int fConnected;
    int fRemembered;
    int fAuthenticated;
    SYSTEMTIME stLastSeen;
    SYSTEMTIME stLastUsed;
    wchar[248] szName;
}

struct BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS
{
    BLUETOOTH_DEVICE_INFO deviceInfo;
    int authenticationMethod;
    int ioCapability;
    int authenticationRequirements;
    _Anonymous_e__Union Anonymous;
}

HSP用 定義

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

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS サイズ: 576 バイト(x64)
dim st, 144    ; 4byte整数×144(構造体サイズ 576 / 4 切り上げ)
; deviceInfo : BLUETOOTH_DEVICE_INFO (+0, 560byte)  varptr(st)+0 を基点に操作(560byte:入れ子/配列)
; authenticationMethod : BLUETOOTH_AUTHENTICATION_METHOD (+560, 4byte)  st.140 = 値  /  値 = st.140   (lpoke/lpeek も可)
; ioCapability : BLUETOOTH_IO_CAPABILITY (+564, 4byte)  st.141 = 値  /  値 = st.141   (lpoke/lpeek も可)
; authenticationRequirements : BLUETOOTH_AUTHENTICATION_REQUIREMENTS (+568, 4byte)  st.142 = 値  /  値 = st.142   (lpoke/lpeek も可)
; Anonymous : _Anonymous_e__Union (+572, 4byte)  varptr(st)+572 を基点に操作(4byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global BLUETOOTH_ADDRESS
    #field byte Anonymous 8
#endstruct

#defstruct global SYSTEMTIME
    #field short wYear
    #field short wMonth
    #field short wDayOfWeek
    #field short wDay
    #field short wHour
    #field short wMinute
    #field short wSecond
    #field short wMilliseconds
#endstruct

#defstruct global BLUETOOTH_DEVICE_INFO
    #field int dwSize
    #field BLUETOOTH_ADDRESS Address
    #field int ulClassofDevice
    #field bool fConnected
    #field bool fRemembered
    #field bool fAuthenticated
    #field SYSTEMTIME stLastSeen
    #field SYSTEMTIME stLastUsed
    #field wchar szName 248
#endstruct

#defstruct global BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS
    #field BLUETOOTH_DEVICE_INFO deviceInfo
    #field int authenticationMethod
    #field int ioCapability
    #field int authenticationRequirements
    #field byte Anonymous 4
#endstruct

stdim st, BLUETOOTH_AUTHENTICATION_CALLBACK_PARAMS        ; NSTRUCT 変数を確保
st->authenticationMethod = 100
mes "authenticationMethod=" + st->authenticationMethod
; ※union フィールドは byte 列で確保(NSTRUCT は union 非対応)。必要に応じ手動でアクセス。