ホーム › Devices.Bluetooth › BluetoothEnumerateInstalledServices
BluetoothEnumerateInstalledServices
関数Bluetoothデバイスにインストール済みのサービスを列挙する。
シグネチャ
// BluetoothApis.dll
#include <windows.h>
DWORD BluetoothEnumerateInstalledServices(
HANDLE hRadio, // optional
const BLUETOOTH_DEVICE_INFO* pbtdi,
DWORD* pcServiceInout,
GUID* pGuidServices // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hRadio | HANDLE | inoptional | サービス列挙に用いるBluetoothラジオのハンドル。NULL可。 |
| pbtdi | BLUETOOTH_DEVICE_INFO* | in | サービスを列挙する対象デバイスの情報構造体ポインタ。 |
| pcServiceInout | DWORD* | inout | 入力でpGuidServices配列の容量、出力で実際のサービス数を表すポインタ。 |
| pGuidServices | GUID* | outoptional | インストール済みサービスのGUID配列を受け取る出力ポインタ。NULLでサイズ照会。 |
戻り値の型: DWORD
各言語での呼び出し定義
// BluetoothApis.dll
#include <windows.h>
DWORD BluetoothEnumerateInstalledServices(
HANDLE hRadio, // optional
const BLUETOOTH_DEVICE_INFO* pbtdi,
DWORD* pcServiceInout,
GUID* pGuidServices // optional
);[DllImport("BluetoothApis.dll", ExactSpelling = true)]
static extern uint BluetoothEnumerateInstalledServices(
IntPtr hRadio, // HANDLE optional
IntPtr pbtdi, // BLUETOOTH_DEVICE_INFO*
ref uint pcServiceInout, // DWORD* in/out
IntPtr pGuidServices // GUID* optional, out
);<DllImport("BluetoothApis.dll", ExactSpelling:=True)>
Public Shared Function BluetoothEnumerateInstalledServices(
hRadio As IntPtr, ' HANDLE optional
pbtdi As IntPtr, ' BLUETOOTH_DEVICE_INFO*
ByRef pcServiceInout As UInteger, ' DWORD* in/out
pGuidServices As IntPtr ' GUID* optional, out
) As UInteger
End Function' hRadio : HANDLE optional
' pbtdi : BLUETOOTH_DEVICE_INFO*
' pcServiceInout : DWORD* in/out
' pGuidServices : GUID* optional, out
Declare PtrSafe Function BluetoothEnumerateInstalledServices Lib "bluetoothapis" ( _
ByVal hRadio As LongPtr, _
ByVal pbtdi As LongPtr, _
ByRef pcServiceInout As Long, _
ByVal pGuidServices As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
BluetoothEnumerateInstalledServices = ctypes.windll.bluetoothapis.BluetoothEnumerateInstalledServices
BluetoothEnumerateInstalledServices.restype = wintypes.DWORD
BluetoothEnumerateInstalledServices.argtypes = [
wintypes.HANDLE, # hRadio : HANDLE optional
ctypes.c_void_p, # pbtdi : BLUETOOTH_DEVICE_INFO*
ctypes.POINTER(wintypes.DWORD), # pcServiceInout : DWORD* in/out
ctypes.c_void_p, # pGuidServices : GUID* optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('BluetoothApis.dll')
BluetoothEnumerateInstalledServices = Fiddle::Function.new(
lib['BluetoothEnumerateInstalledServices'],
[
Fiddle::TYPE_VOIDP, # hRadio : HANDLE optional
Fiddle::TYPE_VOIDP, # pbtdi : BLUETOOTH_DEVICE_INFO*
Fiddle::TYPE_VOIDP, # pcServiceInout : DWORD* in/out
Fiddle::TYPE_VOIDP, # pGuidServices : GUID* optional, out
],
-Fiddle::TYPE_INT)#[link(name = "bluetoothapis")]
extern "system" {
fn BluetoothEnumerateInstalledServices(
hRadio: *mut core::ffi::c_void, // HANDLE optional
pbtdi: *const BLUETOOTH_DEVICE_INFO, // BLUETOOTH_DEVICE_INFO*
pcServiceInout: *mut u32, // DWORD* in/out
pGuidServices: *mut GUID // GUID* optional, out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("BluetoothApis.dll")]
public static extern uint BluetoothEnumerateInstalledServices(IntPtr hRadio, IntPtr pbtdi, ref uint pcServiceInout, IntPtr pGuidServices);
"@
$api = Add-Type -MemberDefinition $sig -Name 'BluetoothApis_BluetoothEnumerateInstalledServices' -Namespace Win32 -PassThru
# $api::BluetoothEnumerateInstalledServices(hRadio, pbtdi, pcServiceInout, pGuidServices)#uselib "BluetoothApis.dll"
#func global BluetoothEnumerateInstalledServices "BluetoothEnumerateInstalledServices" sptr, sptr, sptr, sptr
; BluetoothEnumerateInstalledServices hRadio, varptr(pbtdi), varptr(pcServiceInout), varptr(pGuidServices) ; 戻り値は stat
; hRadio : HANDLE optional -> "sptr"
; pbtdi : BLUETOOTH_DEVICE_INFO* -> "sptr"
; pcServiceInout : DWORD* in/out -> "sptr"
; pGuidServices : GUID* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "BluetoothApis.dll" #cfunc global BluetoothEnumerateInstalledServices "BluetoothEnumerateInstalledServices" sptr, var, var, var ; res = BluetoothEnumerateInstalledServices(hRadio, pbtdi, pcServiceInout, pGuidServices) ; hRadio : HANDLE optional -> "sptr" ; pbtdi : BLUETOOTH_DEVICE_INFO* -> "var" ; pcServiceInout : DWORD* in/out -> "var" ; pGuidServices : GUID* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "BluetoothApis.dll" #cfunc global BluetoothEnumerateInstalledServices "BluetoothEnumerateInstalledServices" sptr, sptr, sptr, sptr ; res = BluetoothEnumerateInstalledServices(hRadio, varptr(pbtdi), varptr(pcServiceInout), varptr(pGuidServices)) ; hRadio : HANDLE optional -> "sptr" ; pbtdi : BLUETOOTH_DEVICE_INFO* -> "sptr" ; pcServiceInout : DWORD* in/out -> "sptr" ; pGuidServices : GUID* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD BluetoothEnumerateInstalledServices(HANDLE hRadio, BLUETOOTH_DEVICE_INFO* pbtdi, DWORD* pcServiceInout, GUID* pGuidServices) #uselib "BluetoothApis.dll" #cfunc global BluetoothEnumerateInstalledServices "BluetoothEnumerateInstalledServices" intptr, var, var, var ; res = BluetoothEnumerateInstalledServices(hRadio, pbtdi, pcServiceInout, pGuidServices) ; hRadio : HANDLE optional -> "intptr" ; pbtdi : BLUETOOTH_DEVICE_INFO* -> "var" ; pcServiceInout : DWORD* in/out -> "var" ; pGuidServices : GUID* optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD BluetoothEnumerateInstalledServices(HANDLE hRadio, BLUETOOTH_DEVICE_INFO* pbtdi, DWORD* pcServiceInout, GUID* pGuidServices) #uselib "BluetoothApis.dll" #cfunc global BluetoothEnumerateInstalledServices "BluetoothEnumerateInstalledServices" intptr, intptr, intptr, intptr ; res = BluetoothEnumerateInstalledServices(hRadio, varptr(pbtdi), varptr(pcServiceInout), varptr(pGuidServices)) ; hRadio : HANDLE optional -> "intptr" ; pbtdi : BLUETOOTH_DEVICE_INFO* -> "intptr" ; pcServiceInout : DWORD* in/out -> "intptr" ; pGuidServices : GUID* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
bluetoothapis = windows.NewLazySystemDLL("BluetoothApis.dll")
procBluetoothEnumerateInstalledServices = bluetoothapis.NewProc("BluetoothEnumerateInstalledServices")
)
// hRadio (HANDLE optional), pbtdi (BLUETOOTH_DEVICE_INFO*), pcServiceInout (DWORD* in/out), pGuidServices (GUID* optional, out)
r1, _, err := procBluetoothEnumerateInstalledServices.Call(
uintptr(hRadio),
uintptr(pbtdi),
uintptr(pcServiceInout),
uintptr(pGuidServices),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction BluetoothEnumerateInstalledServices(
hRadio: THandle; // HANDLE optional
pbtdi: Pointer; // BLUETOOTH_DEVICE_INFO*
pcServiceInout: Pointer; // DWORD* in/out
pGuidServices: PGUID // GUID* optional, out
): DWORD; stdcall;
external 'BluetoothApis.dll' name 'BluetoothEnumerateInstalledServices';result := DllCall("BluetoothApis\BluetoothEnumerateInstalledServices"
, "Ptr", hRadio ; HANDLE optional
, "Ptr", pbtdi ; BLUETOOTH_DEVICE_INFO*
, "Ptr", pcServiceInout ; DWORD* in/out
, "Ptr", pGuidServices ; GUID* optional, out
, "UInt") ; return: DWORD●BluetoothEnumerateInstalledServices(hRadio, pbtdi, pcServiceInout, pGuidServices) = DLL("BluetoothApis.dll", "dword BluetoothEnumerateInstalledServices(void*, void*, void*, void*)")
# 呼び出し: BluetoothEnumerateInstalledServices(hRadio, pbtdi, pcServiceInout, pGuidServices)
# hRadio : HANDLE optional -> "void*"
# pbtdi : BLUETOOTH_DEVICE_INFO* -> "void*"
# pcServiceInout : DWORD* in/out -> "void*"
# pGuidServices : GUID* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "bluetoothapis" fn BluetoothEnumerateInstalledServices(
hRadio: ?*anyopaque, // HANDLE optional
pbtdi: [*c]BLUETOOTH_DEVICE_INFO, // BLUETOOTH_DEVICE_INFO*
pcServiceInout: [*c]u32, // DWORD* in/out
pGuidServices: [*c]GUID // GUID* optional, out
) callconv(std.os.windows.WINAPI) u32;proc BluetoothEnumerateInstalledServices(
hRadio: pointer, # HANDLE optional
pbtdi: ptr BLUETOOTH_DEVICE_INFO, # BLUETOOTH_DEVICE_INFO*
pcServiceInout: ptr uint32, # DWORD* in/out
pGuidServices: ptr GUID # GUID* optional, out
): uint32 {.importc: "BluetoothEnumerateInstalledServices", stdcall, dynlib: "BluetoothApis.dll".}pragma(lib, "bluetoothapis");
extern(Windows)
uint BluetoothEnumerateInstalledServices(
void* hRadio, // HANDLE optional
BLUETOOTH_DEVICE_INFO* pbtdi, // BLUETOOTH_DEVICE_INFO*
uint* pcServiceInout, // DWORD* in/out
GUID* pGuidServices // GUID* optional, out
);ccall((:BluetoothEnumerateInstalledServices, "BluetoothApis.dll"), stdcall, UInt32,
(Ptr{Cvoid}, Ptr{BLUETOOTH_DEVICE_INFO}, Ptr{UInt32}, Ptr{GUID}),
hRadio, pbtdi, pcServiceInout, pGuidServices)
# hRadio : HANDLE optional -> Ptr{Cvoid}
# pbtdi : BLUETOOTH_DEVICE_INFO* -> Ptr{BLUETOOTH_DEVICE_INFO}
# pcServiceInout : DWORD* in/out -> Ptr{UInt32}
# pGuidServices : GUID* optional, out -> Ptr{GUID}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t BluetoothEnumerateInstalledServices(
void* hRadio,
void* pbtdi,
uint32_t* pcServiceInout,
void* pGuidServices);
]]
local bluetoothapis = ffi.load("bluetoothapis")
-- bluetoothapis.BluetoothEnumerateInstalledServices(hRadio, pbtdi, pcServiceInout, pGuidServices)
-- hRadio : HANDLE optional
-- pbtdi : BLUETOOTH_DEVICE_INFO*
-- pcServiceInout : DWORD* in/out
-- pGuidServices : GUID* optional, out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('BluetoothApis.dll');
const BluetoothEnumerateInstalledServices = lib.func('__stdcall', 'BluetoothEnumerateInstalledServices', 'uint32_t', ['void *', 'void *', 'uint32_t *', 'void *']);
// BluetoothEnumerateInstalledServices(hRadio, pbtdi, pcServiceInout, pGuidServices)
// hRadio : HANDLE optional -> 'void *'
// pbtdi : BLUETOOTH_DEVICE_INFO* -> 'void *'
// pcServiceInout : DWORD* in/out -> 'uint32_t *'
// pGuidServices : GUID* optional, out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("BluetoothApis.dll", {
BluetoothEnumerateInstalledServices: { parameters: ["pointer", "pointer", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.BluetoothEnumerateInstalledServices(hRadio, pbtdi, pcServiceInout, pGuidServices)
// hRadio : HANDLE optional -> "pointer"
// pbtdi : BLUETOOTH_DEVICE_INFO* -> "pointer"
// pcServiceInout : DWORD* in/out -> "pointer"
// pGuidServices : GUID* optional, out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t BluetoothEnumerateInstalledServices(
void* hRadio,
void* pbtdi,
uint32_t* pcServiceInout,
void* pGuidServices);
C, "BluetoothApis.dll");
// $ffi->BluetoothEnumerateInstalledServices(hRadio, pbtdi, pcServiceInout, pGuidServices);
// hRadio : HANDLE optional
// pbtdi : BLUETOOTH_DEVICE_INFO*
// pcServiceInout : DWORD* in/out
// pGuidServices : GUID* optional, out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Bluetoothapis extends StdCallLibrary {
Bluetoothapis INSTANCE = Native.load("bluetoothapis", Bluetoothapis.class);
int BluetoothEnumerateInstalledServices(
Pointer hRadio, // HANDLE optional
Pointer pbtdi, // BLUETOOTH_DEVICE_INFO*
IntByReference pcServiceInout, // DWORD* in/out
Pointer pGuidServices // GUID* optional, out
);
}@[Link("bluetoothapis")]
lib LibBluetoothApis
fun BluetoothEnumerateInstalledServices = BluetoothEnumerateInstalledServices(
hRadio : Void*, # HANDLE optional
pbtdi : BLUETOOTH_DEVICE_INFO*, # BLUETOOTH_DEVICE_INFO*
pcServiceInout : UInt32*, # DWORD* in/out
pGuidServices : GUID* # GUID* optional, out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef BluetoothEnumerateInstalledServicesNative = Uint32 Function(Pointer<Void>, Pointer<Void>, Pointer<Uint32>, Pointer<Void>);
typedef BluetoothEnumerateInstalledServicesDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Uint32>, Pointer<Void>);
final BluetoothEnumerateInstalledServices = DynamicLibrary.open('BluetoothApis.dll')
.lookupFunction<BluetoothEnumerateInstalledServicesNative, BluetoothEnumerateInstalledServicesDart>('BluetoothEnumerateInstalledServices');
// hRadio : HANDLE optional -> Pointer<Void>
// pbtdi : BLUETOOTH_DEVICE_INFO* -> Pointer<Void>
// pcServiceInout : DWORD* in/out -> Pointer<Uint32>
// pGuidServices : GUID* optional, out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function BluetoothEnumerateInstalledServices(
hRadio: THandle; // HANDLE optional
pbtdi: Pointer; // BLUETOOTH_DEVICE_INFO*
pcServiceInout: Pointer; // DWORD* in/out
pGuidServices: PGUID // GUID* optional, out
): DWORD; stdcall;
external 'BluetoothApis.dll' name 'BluetoothEnumerateInstalledServices';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "BluetoothEnumerateInstalledServices"
c_BluetoothEnumerateInstalledServices :: Ptr () -> Ptr () -> Ptr Word32 -> Ptr () -> IO Word32
-- hRadio : HANDLE optional -> Ptr ()
-- pbtdi : BLUETOOTH_DEVICE_INFO* -> Ptr ()
-- pcServiceInout : DWORD* in/out -> Ptr Word32
-- pGuidServices : GUID* optional, out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let bluetoothenumerateinstalledservices =
foreign "BluetoothEnumerateInstalledServices"
((ptr void) @-> (ptr void) @-> (ptr uint32_t) @-> (ptr void) @-> returning uint32_t)
(* hRadio : HANDLE optional -> (ptr void) *)
(* pbtdi : BLUETOOTH_DEVICE_INFO* -> (ptr void) *)
(* pcServiceInout : DWORD* in/out -> (ptr uint32_t) *)
(* pGuidServices : GUID* optional, out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library bluetoothapis (t "BluetoothApis.dll"))
(cffi:use-foreign-library bluetoothapis)
(cffi:defcfun ("BluetoothEnumerateInstalledServices" bluetooth-enumerate-installed-services :convention :stdcall) :uint32
(h-radio :pointer) ; HANDLE optional
(pbtdi :pointer) ; BLUETOOTH_DEVICE_INFO*
(pc-service-inout :pointer) ; DWORD* in/out
(p-guid-services :pointer)) ; GUID* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $BluetoothEnumerateInstalledServices = Win32::API::More->new('BluetoothApis',
'DWORD BluetoothEnumerateInstalledServices(HANDLE hRadio, LPVOID pbtdi, LPVOID pcServiceInout, LPVOID pGuidServices)');
# my $ret = $BluetoothEnumerateInstalledServices->Call($hRadio, $pbtdi, $pcServiceInout, $pGuidServices);
# hRadio : HANDLE optional -> HANDLE
# pbtdi : BLUETOOTH_DEVICE_INFO* -> LPVOID
# pcServiceInout : DWORD* in/out -> LPVOID
# pGuidServices : GUID* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。