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

BluetoothRegisterForAuthentication

関数
Bluetooth認証要求のコールバックを登録する。
DLLBluetoothApis.dll呼出規約winapiSetLastErrorあり対応OSWindows Vista 以降

シグネチャ

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

DWORD BluetoothRegisterForAuthentication(
    const BLUETOOTH_DEVICE_INFO* pbtdi,   // optional
    INT_PTR* phRegHandle,
    PFN_AUTHENTICATION_CALLBACK pfnCallback,   // optional
    void* pvParam   // optional
);

パラメーター

名前方向
pbtdiBLUETOOTH_DEVICE_INFO*inoptional
phRegHandleINT_PTR*out
pfnCallbackPFN_AUTHENTICATION_CALLBACKinoptional
pvParamvoid*inoptional

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD BluetoothRegisterForAuthentication(
    const BLUETOOTH_DEVICE_INFO* pbtdi,   // optional
    INT_PTR* phRegHandle,
    PFN_AUTHENTICATION_CALLBACK pfnCallback,   // optional
    void* pvParam   // optional
);
[DllImport("BluetoothApis.dll", SetLastError = true, ExactSpelling = true)]
static extern uint BluetoothRegisterForAuthentication(
    IntPtr pbtdi,   // BLUETOOTH_DEVICE_INFO* optional
    out IntPtr phRegHandle,   // INT_PTR* out
    IntPtr pfnCallback,   // PFN_AUTHENTICATION_CALLBACK optional
    IntPtr pvParam   // void* optional
);
<DllImport("BluetoothApis.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function BluetoothRegisterForAuthentication(
    pbtdi As IntPtr,   ' BLUETOOTH_DEVICE_INFO* optional
    <Out> ByRef phRegHandle As IntPtr,   ' INT_PTR* out
    pfnCallback As IntPtr,   ' PFN_AUTHENTICATION_CALLBACK optional
    pvParam As IntPtr   ' void* optional
) As UInteger
End Function
' pbtdi : BLUETOOTH_DEVICE_INFO* optional
' phRegHandle : INT_PTR* out
' pfnCallback : PFN_AUTHENTICATION_CALLBACK optional
' pvParam : void* optional
Declare PtrSafe Function BluetoothRegisterForAuthentication Lib "bluetoothapis" ( _
    ByVal pbtdi As LongPtr, _
    ByRef phRegHandle As LongPtr, _
    ByVal pfnCallback As LongPtr, _
    ByVal pvParam As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

BluetoothRegisterForAuthentication = ctypes.windll.bluetoothapis.BluetoothRegisterForAuthentication
BluetoothRegisterForAuthentication.restype = wintypes.DWORD
BluetoothRegisterForAuthentication.argtypes = [
    ctypes.c_void_p,  # pbtdi : BLUETOOTH_DEVICE_INFO* optional
    ctypes.POINTER(ctypes.c_ssize_t),  # phRegHandle : INT_PTR* out
    ctypes.c_void_p,  # pfnCallback : PFN_AUTHENTICATION_CALLBACK optional
    ctypes.POINTER(None),  # pvParam : void* optional
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('BluetoothApis.dll')
BluetoothRegisterForAuthentication = Fiddle::Function.new(
  lib['BluetoothRegisterForAuthentication'],
  [
    Fiddle::TYPE_VOIDP,  # pbtdi : BLUETOOTH_DEVICE_INFO* optional
    Fiddle::TYPE_VOIDP,  # phRegHandle : INT_PTR* out
    Fiddle::TYPE_VOIDP,  # pfnCallback : PFN_AUTHENTICATION_CALLBACK optional
    Fiddle::TYPE_VOIDP,  # pvParam : void* optional
  ],
  -Fiddle::TYPE_INT)
#[link(name = "bluetoothapis")]
extern "system" {
    fn BluetoothRegisterForAuthentication(
        pbtdi: *const BLUETOOTH_DEVICE_INFO,  // BLUETOOTH_DEVICE_INFO* optional
        phRegHandle: *mut isize,  // INT_PTR* out
        pfnCallback: *const core::ffi::c_void,  // PFN_AUTHENTICATION_CALLBACK optional
        pvParam: *mut ()  // void* optional
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("BluetoothApis.dll", SetLastError = true)]
public static extern uint BluetoothRegisterForAuthentication(IntPtr pbtdi, out IntPtr phRegHandle, IntPtr pfnCallback, IntPtr pvParam);
"@
$api = Add-Type -MemberDefinition $sig -Name 'BluetoothApis_BluetoothRegisterForAuthentication' -Namespace Win32 -PassThru
# $api::BluetoothRegisterForAuthentication(pbtdi, phRegHandle, pfnCallback, pvParam)
#uselib "BluetoothApis.dll"
#func global BluetoothRegisterForAuthentication "BluetoothRegisterForAuthentication" sptr, sptr, sptr, sptr
; BluetoothRegisterForAuthentication varptr(pbtdi), varptr(phRegHandle), pfnCallback, pvParam   ; 戻り値は stat
; pbtdi : BLUETOOTH_DEVICE_INFO* optional -> "sptr"
; phRegHandle : INT_PTR* out -> "sptr"
; pfnCallback : PFN_AUTHENTICATION_CALLBACK optional -> "sptr"
; pvParam : void* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "BluetoothApis.dll"
#cfunc global BluetoothRegisterForAuthentication "BluetoothRegisterForAuthentication" var, var, sptr, sptr
; res = BluetoothRegisterForAuthentication(pbtdi, phRegHandle, pfnCallback, pvParam)
; pbtdi : BLUETOOTH_DEVICE_INFO* optional -> "var"
; phRegHandle : INT_PTR* out -> "var"
; pfnCallback : PFN_AUTHENTICATION_CALLBACK optional -> "sptr"
; pvParam : void* optional -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD BluetoothRegisterForAuthentication(BLUETOOTH_DEVICE_INFO* pbtdi, INT_PTR* phRegHandle, PFN_AUTHENTICATION_CALLBACK pfnCallback, void* pvParam)
#uselib "BluetoothApis.dll"
#cfunc global BluetoothRegisterForAuthentication "BluetoothRegisterForAuthentication" var, var, intptr, intptr
; res = BluetoothRegisterForAuthentication(pbtdi, phRegHandle, pfnCallback, pvParam)
; pbtdi : BLUETOOTH_DEVICE_INFO* optional -> "var"
; phRegHandle : INT_PTR* out -> "var"
; pfnCallback : PFN_AUTHENTICATION_CALLBACK optional -> "intptr"
; pvParam : void* optional -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	bluetoothapis = windows.NewLazySystemDLL("BluetoothApis.dll")
	procBluetoothRegisterForAuthentication = bluetoothapis.NewProc("BluetoothRegisterForAuthentication")
)

// pbtdi (BLUETOOTH_DEVICE_INFO* optional), phRegHandle (INT_PTR* out), pfnCallback (PFN_AUTHENTICATION_CALLBACK optional), pvParam (void* optional)
r1, _, err := procBluetoothRegisterForAuthentication.Call(
	uintptr(pbtdi),
	uintptr(phRegHandle),
	uintptr(pfnCallback),
	uintptr(pvParam),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function BluetoothRegisterForAuthentication(
  pbtdi: Pointer;   // BLUETOOTH_DEVICE_INFO* optional
  phRegHandle: Pointer;   // INT_PTR* out
  pfnCallback: Pointer;   // PFN_AUTHENTICATION_CALLBACK optional
  pvParam: Pointer   // void* optional
): DWORD; stdcall;
  external 'BluetoothApis.dll' name 'BluetoothRegisterForAuthentication';
result := DllCall("BluetoothApis\BluetoothRegisterForAuthentication"
    , "Ptr", pbtdi   ; BLUETOOTH_DEVICE_INFO* optional
    , "Ptr", phRegHandle   ; INT_PTR* out
    , "Ptr", pfnCallback   ; PFN_AUTHENTICATION_CALLBACK optional
    , "Ptr", pvParam   ; void* optional
    , "UInt")   ; return: DWORD
●BluetoothRegisterForAuthentication(pbtdi, phRegHandle, pfnCallback, pvParam) = DLL("BluetoothApis.dll", "dword BluetoothRegisterForAuthentication(void*, void*, void*, void*)")
# 呼び出し: BluetoothRegisterForAuthentication(pbtdi, phRegHandle, pfnCallback, pvParam)
# pbtdi : BLUETOOTH_DEVICE_INFO* optional -> "void*"
# phRegHandle : INT_PTR* out -> "void*"
# pfnCallback : PFN_AUTHENTICATION_CALLBACK optional -> "void*"
# pvParam : void* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。