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

BluetoothAuthenticateDeviceEx

関数
認証要件を指定してBluetoothデバイスを認証する。
DLLbthprops.cpl呼出規約winapi対応OSWindows XP 以降

シグネチャ

// bthprops.cpl
#include <windows.h>

DWORD BluetoothAuthenticateDeviceEx(
    HWND hwndParentIn,   // optional
    HANDLE hRadioIn,   // optional
    BLUETOOTH_DEVICE_INFO* pbtdiInout,
    BLUETOOTH_OOB_DATA_INFO* pbtOobData,   // optional
    AUTHENTICATION_REQUIREMENTS authenticationRequirement
);

パラメーター

名前方向
hwndParentInHWNDinoptional
hRadioInHANDLEinoptional
pbtdiInoutBLUETOOTH_DEVICE_INFO*inout
pbtOobDataBLUETOOTH_OOB_DATA_INFO*inoptional
authenticationRequirementAUTHENTICATION_REQUIREMENTSin

戻り値の型: DWORD

各言語での呼び出し定義

// bthprops.cpl
#include <windows.h>

DWORD BluetoothAuthenticateDeviceEx(
    HWND hwndParentIn,   // optional
    HANDLE hRadioIn,   // optional
    BLUETOOTH_DEVICE_INFO* pbtdiInout,
    BLUETOOTH_OOB_DATA_INFO* pbtOobData,   // optional
    AUTHENTICATION_REQUIREMENTS authenticationRequirement
);
[DllImport("bthprops.cpl", ExactSpelling = true)]
static extern uint BluetoothAuthenticateDeviceEx(
    IntPtr hwndParentIn,   // HWND optional
    IntPtr hRadioIn,   // HANDLE optional
    IntPtr pbtdiInout,   // BLUETOOTH_DEVICE_INFO* in/out
    IntPtr pbtOobData,   // BLUETOOTH_OOB_DATA_INFO* optional
    int authenticationRequirement   // AUTHENTICATION_REQUIREMENTS
);
<DllImport("bthprops.cpl", ExactSpelling:=True)>
Public Shared Function BluetoothAuthenticateDeviceEx(
    hwndParentIn As IntPtr,   ' HWND optional
    hRadioIn As IntPtr,   ' HANDLE optional
    pbtdiInout As IntPtr,   ' BLUETOOTH_DEVICE_INFO* in/out
    pbtOobData As IntPtr,   ' BLUETOOTH_OOB_DATA_INFO* optional
    authenticationRequirement As Integer   ' AUTHENTICATION_REQUIREMENTS
) As UInteger
End Function
' hwndParentIn : HWND optional
' hRadioIn : HANDLE optional
' pbtdiInout : BLUETOOTH_DEVICE_INFO* in/out
' pbtOobData : BLUETOOTH_OOB_DATA_INFO* optional
' authenticationRequirement : AUTHENTICATION_REQUIREMENTS
Declare PtrSafe Function BluetoothAuthenticateDeviceEx Lib "bthprops.cpl" ( _
    ByVal hwndParentIn As LongPtr, _
    ByVal hRadioIn As LongPtr, _
    ByVal pbtdiInout As LongPtr, _
    ByVal pbtOobData As LongPtr, _
    ByVal authenticationRequirement As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

BluetoothAuthenticateDeviceEx = ctypes.windll.LoadLibrary("bthprops.cpl").BluetoothAuthenticateDeviceEx
BluetoothAuthenticateDeviceEx.restype = wintypes.DWORD
BluetoothAuthenticateDeviceEx.argtypes = [
    wintypes.HANDLE,  # hwndParentIn : HWND optional
    wintypes.HANDLE,  # hRadioIn : HANDLE optional
    ctypes.c_void_p,  # pbtdiInout : BLUETOOTH_DEVICE_INFO* in/out
    ctypes.c_void_p,  # pbtOobData : BLUETOOTH_OOB_DATA_INFO* optional
    ctypes.c_int,  # authenticationRequirement : AUTHENTICATION_REQUIREMENTS
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('bthprops.cpl')
BluetoothAuthenticateDeviceEx = Fiddle::Function.new(
  lib['BluetoothAuthenticateDeviceEx'],
  [
    Fiddle::TYPE_VOIDP,  # hwndParentIn : HWND optional
    Fiddle::TYPE_VOIDP,  # hRadioIn : HANDLE optional
    Fiddle::TYPE_VOIDP,  # pbtdiInout : BLUETOOTH_DEVICE_INFO* in/out
    Fiddle::TYPE_VOIDP,  # pbtOobData : BLUETOOTH_OOB_DATA_INFO* optional
    Fiddle::TYPE_INT,  # authenticationRequirement : AUTHENTICATION_REQUIREMENTS
  ],
  -Fiddle::TYPE_INT)
#[link(name = "bthprops.cpl")]
extern "system" {
    fn BluetoothAuthenticateDeviceEx(
        hwndParentIn: *mut core::ffi::c_void,  // HWND optional
        hRadioIn: *mut core::ffi::c_void,  // HANDLE optional
        pbtdiInout: *mut BLUETOOTH_DEVICE_INFO,  // BLUETOOTH_DEVICE_INFO* in/out
        pbtOobData: *mut BLUETOOTH_OOB_DATA_INFO,  // BLUETOOTH_OOB_DATA_INFO* optional
        authenticationRequirement: i32  // AUTHENTICATION_REQUIREMENTS
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("bthprops.cpl")]
public static extern uint BluetoothAuthenticateDeviceEx(IntPtr hwndParentIn, IntPtr hRadioIn, IntPtr pbtdiInout, IntPtr pbtOobData, int authenticationRequirement);
"@
$api = Add-Type -MemberDefinition $sig -Name 'bthprops.cpl_BluetoothAuthenticateDeviceEx' -Namespace Win32 -PassThru
# $api::BluetoothAuthenticateDeviceEx(hwndParentIn, hRadioIn, pbtdiInout, pbtOobData, authenticationRequirement)
#uselib "bthprops.cpl"
#func global BluetoothAuthenticateDeviceEx "BluetoothAuthenticateDeviceEx" sptr, sptr, sptr, sptr, sptr
; BluetoothAuthenticateDeviceEx hwndParentIn, hRadioIn, varptr(pbtdiInout), varptr(pbtOobData), authenticationRequirement   ; 戻り値は stat
; hwndParentIn : HWND optional -> "sptr"
; hRadioIn : HANDLE optional -> "sptr"
; pbtdiInout : BLUETOOTH_DEVICE_INFO* in/out -> "sptr"
; pbtOobData : BLUETOOTH_OOB_DATA_INFO* optional -> "sptr"
; authenticationRequirement : AUTHENTICATION_REQUIREMENTS -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "bthprops.cpl"
#cfunc global BluetoothAuthenticateDeviceEx "BluetoothAuthenticateDeviceEx" sptr, sptr, var, var, int
; res = BluetoothAuthenticateDeviceEx(hwndParentIn, hRadioIn, pbtdiInout, pbtOobData, authenticationRequirement)
; hwndParentIn : HWND optional -> "sptr"
; hRadioIn : HANDLE optional -> "sptr"
; pbtdiInout : BLUETOOTH_DEVICE_INFO* in/out -> "var"
; pbtOobData : BLUETOOTH_OOB_DATA_INFO* optional -> "var"
; authenticationRequirement : AUTHENTICATION_REQUIREMENTS -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD BluetoothAuthenticateDeviceEx(HWND hwndParentIn, HANDLE hRadioIn, BLUETOOTH_DEVICE_INFO* pbtdiInout, BLUETOOTH_OOB_DATA_INFO* pbtOobData, AUTHENTICATION_REQUIREMENTS authenticationRequirement)
#uselib "bthprops.cpl"
#cfunc global BluetoothAuthenticateDeviceEx "BluetoothAuthenticateDeviceEx" intptr, intptr, var, var, int
; res = BluetoothAuthenticateDeviceEx(hwndParentIn, hRadioIn, pbtdiInout, pbtOobData, authenticationRequirement)
; hwndParentIn : HWND optional -> "intptr"
; hRadioIn : HANDLE optional -> "intptr"
; pbtdiInout : BLUETOOTH_DEVICE_INFO* in/out -> "var"
; pbtOobData : BLUETOOTH_OOB_DATA_INFO* optional -> "var"
; authenticationRequirement : AUTHENTICATION_REQUIREMENTS -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	bthprops_cpl = windows.NewLazySystemDLL("bthprops.cpl")
	procBluetoothAuthenticateDeviceEx = bthprops_cpl.NewProc("BluetoothAuthenticateDeviceEx")
)

// hwndParentIn (HWND optional), hRadioIn (HANDLE optional), pbtdiInout (BLUETOOTH_DEVICE_INFO* in/out), pbtOobData (BLUETOOTH_OOB_DATA_INFO* optional), authenticationRequirement (AUTHENTICATION_REQUIREMENTS)
r1, _, err := procBluetoothAuthenticateDeviceEx.Call(
	uintptr(hwndParentIn),
	uintptr(hRadioIn),
	uintptr(pbtdiInout),
	uintptr(pbtOobData),
	uintptr(authenticationRequirement),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function BluetoothAuthenticateDeviceEx(
  hwndParentIn: THandle;   // HWND optional
  hRadioIn: THandle;   // HANDLE optional
  pbtdiInout: Pointer;   // BLUETOOTH_DEVICE_INFO* in/out
  pbtOobData: Pointer;   // BLUETOOTH_OOB_DATA_INFO* optional
  authenticationRequirement: Integer   // AUTHENTICATION_REQUIREMENTS
): DWORD; stdcall;
  external 'bthprops.cpl' name 'BluetoothAuthenticateDeviceEx';
result := DllCall("bthprops.cpl\BluetoothAuthenticateDeviceEx"
    , "Ptr", hwndParentIn   ; HWND optional
    , "Ptr", hRadioIn   ; HANDLE optional
    , "Ptr", pbtdiInout   ; BLUETOOTH_DEVICE_INFO* in/out
    , "Ptr", pbtOobData   ; BLUETOOTH_OOB_DATA_INFO* optional
    , "Int", authenticationRequirement   ; AUTHENTICATION_REQUIREMENTS
    , "UInt")   ; return: DWORD
●BluetoothAuthenticateDeviceEx(hwndParentIn, hRadioIn, pbtdiInout, pbtOobData, authenticationRequirement) = DLL("bthprops.cpl", "dword BluetoothAuthenticateDeviceEx(void*, void*, void*, void*, int)")
# 呼び出し: BluetoothAuthenticateDeviceEx(hwndParentIn, hRadioIn, pbtdiInout, pbtOobData, authenticationRequirement)
# hwndParentIn : HWND optional -> "void*"
# hRadioIn : HANDLE optional -> "void*"
# pbtdiInout : BLUETOOTH_DEVICE_INFO* in/out -> "void*"
# pbtOobData : BLUETOOTH_OOB_DATA_INFO* optional -> "void*"
# authenticationRequirement : AUTHENTICATION_REQUIREMENTS -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。