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

BluetoothEnumerateInstalledServices

関数
Bluetoothデバイスにインストール済みのサービスを列挙する。
DLLBluetoothApis.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

// BluetoothApis.dll
#include <windows.h>

DWORD BluetoothEnumerateInstalledServices(
    HANDLE hRadio,   // optional
    const BLUETOOTH_DEVICE_INFO* pbtdi,
    DWORD* pcServiceInout,
    GUID* pGuidServices   // optional
);

パラメーター

名前方向
hRadioHANDLEinoptional
pbtdiBLUETOOTH_DEVICE_INFO*in
pcServiceInoutDWORD*inout
pGuidServicesGUID*outoptional

戻り値の型: 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 方式にも切替可。
出力引数:
; 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 方式にも切替可。
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   // DWORD
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';
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)。