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

BLUETOOTH_LOCAL_SERVICE_INFO

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

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

フィールド

フィールドサイズx64x86説明
EnabledBOOL4+0+0サービスが有効か無効かを示すBOOL値。TRUEで有効。
btAddrBLUETOOTH_ADDRESS8+8+8サービスを公開するローカルラジオのBluetoothアドレス。
szNameWCHAR512+16+16サービスのフレンドリ名を保持するワイド文字配列。
szDeviceStringWCHAR512+528+528デバイスを識別する文字列を保持するワイド文字配列。COMポート名等に用いる。

各言語での定義

#include <windows.h>

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

// BLUETOOTH_LOCAL_SERVICE_INFO  (x64 1040 / x86 1040 バイト)
typedef struct BLUETOOTH_LOCAL_SERVICE_INFO {
    BOOL Enabled;
    BLUETOOTH_ADDRESS btAddr;
    WCHAR szName[256];
    WCHAR szDeviceString[256];
} BLUETOOTH_LOCAL_SERVICE_INFO;
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 BLUETOOTH_LOCAL_SERVICE_INFO
{
    [MarshalAs(UnmanagedType.Bool)] public bool Enabled;
    public BLUETOOTH_ADDRESS btAddr;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string szName;
    [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string szDeviceString;
}
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 BLUETOOTH_LOCAL_SERVICE_INFO
    <MarshalAs(UnmanagedType.Bool)> Public Enabled As Boolean
    Public btAddr As BLUETOOTH_ADDRESS
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Public szName As String
    <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Public szDeviceString As String
End Structure
import ctypes
from ctypes import wintypes

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

class BLUETOOTH_LOCAL_SERVICE_INFO(ctypes.Structure):
    _fields_ = [
        ("Enabled", wintypes.BOOL),
        ("btAddr", BLUETOOTH_ADDRESS),
        ("szName", ctypes.c_wchar * 256),
        ("szDeviceString", ctypes.c_wchar * 256),
    ]
#[repr(C)]
pub struct BLUETOOTH_ADDRESS {
    pub Anonymous: _Anonymous_e__Union,
}

#[repr(C)]
pub struct BLUETOOTH_LOCAL_SERVICE_INFO {
    pub Enabled: i32,
    pub btAddr: BLUETOOTH_ADDRESS,
    pub szName: [u16; 256],
    pub szDeviceString: [u16; 256],
}
import "golang.org/x/sys/windows"

type BLUETOOTH_ADDRESS struct {
	Anonymous _Anonymous_e__Union
}

type BLUETOOTH_LOCAL_SERVICE_INFO struct {
	Enabled int32
	btAddr BLUETOOTH_ADDRESS
	szName [256]uint16
	szDeviceString [256]uint16
}
type
  BLUETOOTH_ADDRESS = record
    Anonymous: _Anonymous_e__Union;
  end;

  BLUETOOTH_LOCAL_SERVICE_INFO = record
    Enabled: BOOL;
    btAddr: BLUETOOTH_ADDRESS;
    szName: array[0..255] of WideChar;
    szDeviceString: array[0..255] of WideChar;
  end;
const BLUETOOTH_ADDRESS = extern struct {
    Anonymous: _Anonymous_e__Union,
};

const BLUETOOTH_LOCAL_SERVICE_INFO = extern struct {
    Enabled: i32,
    btAddr: BLUETOOTH_ADDRESS,
    szName: [256]u16,
    szDeviceString: [256]u16,
};
type
  BLUETOOTH_ADDRESS {.bycopy.} = object
    Anonymous: _Anonymous_e__Union

  BLUETOOTH_LOCAL_SERVICE_INFO {.bycopy.} = object
    Enabled: int32
    btAddr: BLUETOOTH_ADDRESS
    szName: array[256, uint16]
    szDeviceString: array[256, uint16]
struct BLUETOOTH_ADDRESS
{
    _Anonymous_e__Union Anonymous;
}

struct BLUETOOTH_LOCAL_SERVICE_INFO
{
    int Enabled;
    BLUETOOTH_ADDRESS btAddr;
    wchar[256] szName;
    wchar[256] szDeviceString;
}

HSP用 定義

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

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

#defstruct global BLUETOOTH_LOCAL_SERVICE_INFO
    #field bool Enabled
    #field BLUETOOTH_ADDRESS btAddr
    #field wchar szName 256
    #field wchar szDeviceString 256
#endstruct

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