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