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

BluetoothRegisterForAuthenticationEx

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

シグネチャ

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

DWORD BluetoothRegisterForAuthenticationEx(
    const BLUETOOTH_DEVICE_INFO* pbtdiIn,   // optional
    INT_PTR* phRegHandleOut,
    PFN_AUTHENTICATION_CALLBACK_EX pfnCallbackIn,   // optional
    void* pvParam   // optional
);

パラメーター

名前方向説明
pbtdiInBLUETOOTH_DEVICE_INFO*inoptional認証通知を受け取る対象デバイスの情報構造体ポインタ。NULLで全デバイス対象。
phRegHandleOutINT_PTR*out登録ハンドルを受け取る出力ポインタ。登録解除時に使用。
pfnCallbackInPFN_AUTHENTICATION_CALLBACK_EXinoptional認証要求時に呼ばれる拡張コールバック関数へのポインタ。
pvParamvoid*inoptionalコールバックに渡される任意のパラメータポインタ。NULL可。

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD BluetoothRegisterForAuthenticationEx(
    const BLUETOOTH_DEVICE_INFO* pbtdiIn,   // optional
    INT_PTR* phRegHandleOut,
    PFN_AUTHENTICATION_CALLBACK_EX pfnCallbackIn,   // optional
    void* pvParam   // optional
);
[DllImport("BluetoothApis.dll", ExactSpelling = true)]
static extern uint BluetoothRegisterForAuthenticationEx(
    IntPtr pbtdiIn,   // BLUETOOTH_DEVICE_INFO* optional
    out IntPtr phRegHandleOut,   // INT_PTR* out
    IntPtr pfnCallbackIn,   // PFN_AUTHENTICATION_CALLBACK_EX optional
    IntPtr pvParam   // void* optional
);
<DllImport("BluetoothApis.dll", ExactSpelling:=True)>
Public Shared Function BluetoothRegisterForAuthenticationEx(
    pbtdiIn As IntPtr,   ' BLUETOOTH_DEVICE_INFO* optional
    <Out> ByRef phRegHandleOut As IntPtr,   ' INT_PTR* out
    pfnCallbackIn As IntPtr,   ' PFN_AUTHENTICATION_CALLBACK_EX optional
    pvParam As IntPtr   ' void* optional
) As UInteger
End Function
' pbtdiIn : BLUETOOTH_DEVICE_INFO* optional
' phRegHandleOut : INT_PTR* out
' pfnCallbackIn : PFN_AUTHENTICATION_CALLBACK_EX optional
' pvParam : void* optional
Declare PtrSafe Function BluetoothRegisterForAuthenticationEx Lib "bluetoothapis" ( _
    ByVal pbtdiIn As LongPtr, _
    ByRef phRegHandleOut As LongPtr, _
    ByVal pfnCallbackIn 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

BluetoothRegisterForAuthenticationEx = ctypes.windll.bluetoothapis.BluetoothRegisterForAuthenticationEx
BluetoothRegisterForAuthenticationEx.restype = wintypes.DWORD
BluetoothRegisterForAuthenticationEx.argtypes = [
    ctypes.c_void_p,  # pbtdiIn : BLUETOOTH_DEVICE_INFO* optional
    ctypes.POINTER(ctypes.c_ssize_t),  # phRegHandleOut : INT_PTR* out
    ctypes.c_void_p,  # pfnCallbackIn : PFN_AUTHENTICATION_CALLBACK_EX optional
    ctypes.POINTER(None),  # pvParam : void* optional
]
require 'fiddle'
require 'fiddle/import'

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

var (
	bluetoothapis = windows.NewLazySystemDLL("BluetoothApis.dll")
	procBluetoothRegisterForAuthenticationEx = bluetoothapis.NewProc("BluetoothRegisterForAuthenticationEx")
)

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

extern "bluetoothapis" fn BluetoothRegisterForAuthenticationEx(
    pbtdiIn: [*c]BLUETOOTH_DEVICE_INFO, // BLUETOOTH_DEVICE_INFO* optional
    phRegHandleOut: [*c]isize, // INT_PTR* out
    pfnCallbackIn: ?*anyopaque, // PFN_AUTHENTICATION_CALLBACK_EX optional
    pvParam: ?*anyopaque // void* optional
) callconv(std.os.windows.WINAPI) u32;
proc BluetoothRegisterForAuthenticationEx(
    pbtdiIn: ptr BLUETOOTH_DEVICE_INFO,  # BLUETOOTH_DEVICE_INFO* optional
    phRegHandleOut: ptr int,  # INT_PTR* out
    pfnCallbackIn: pointer,  # PFN_AUTHENTICATION_CALLBACK_EX optional
    pvParam: pointer  # void* optional
): uint32 {.importc: "BluetoothRegisterForAuthenticationEx", stdcall, dynlib: "BluetoothApis.dll".}
pragma(lib, "bluetoothapis");
extern(Windows)
uint BluetoothRegisterForAuthenticationEx(
    BLUETOOTH_DEVICE_INFO* pbtdiIn,   // BLUETOOTH_DEVICE_INFO* optional
    ptrdiff_t* phRegHandleOut,   // INT_PTR* out
    void* pfnCallbackIn,   // PFN_AUTHENTICATION_CALLBACK_EX optional
    void* pvParam   // void* optional
);
ccall((:BluetoothRegisterForAuthenticationEx, "BluetoothApis.dll"), stdcall, UInt32,
      (Ptr{BLUETOOTH_DEVICE_INFO}, Ptr{Int}, Ptr{Cvoid}, Ptr{Cvoid}),
      pbtdiIn, phRegHandleOut, pfnCallbackIn, pvParam)
# pbtdiIn : BLUETOOTH_DEVICE_INFO* optional -> Ptr{BLUETOOTH_DEVICE_INFO}
# phRegHandleOut : INT_PTR* out -> Ptr{Int}
# pfnCallbackIn : PFN_AUTHENTICATION_CALLBACK_EX optional -> Ptr{Cvoid}
# pvParam : void* optional -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
uint32_t BluetoothRegisterForAuthenticationEx(
    void* pbtdiIn,
    intptr_t* phRegHandleOut,
    void* pfnCallbackIn,
    void* pvParam);
]]
local bluetoothapis = ffi.load("bluetoothapis")
-- bluetoothapis.BluetoothRegisterForAuthenticationEx(pbtdiIn, phRegHandleOut, pfnCallbackIn, pvParam)
-- pbtdiIn : BLUETOOTH_DEVICE_INFO* optional
-- phRegHandleOut : INT_PTR* out
-- pfnCallbackIn : PFN_AUTHENTICATION_CALLBACK_EX optional
-- pvParam : void* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('BluetoothApis.dll');
const BluetoothRegisterForAuthenticationEx = lib.func('__stdcall', 'BluetoothRegisterForAuthenticationEx', 'uint32_t', ['void *', 'intptr_t *', 'void *', 'void *']);
// BluetoothRegisterForAuthenticationEx(pbtdiIn, phRegHandleOut, pfnCallbackIn, pvParam)
// pbtdiIn : BLUETOOTH_DEVICE_INFO* optional -> 'void *'
// phRegHandleOut : INT_PTR* out -> 'intptr_t *'
// pfnCallbackIn : PFN_AUTHENTICATION_CALLBACK_EX optional -> 'void *'
// pvParam : void* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。
const lib = Deno.dlopen("BluetoothApis.dll", {
  BluetoothRegisterForAuthenticationEx: { parameters: ["pointer", "pointer", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.BluetoothRegisterForAuthenticationEx(pbtdiIn, phRegHandleOut, pfnCallbackIn, pvParam)
// pbtdiIn : BLUETOOTH_DEVICE_INFO* optional -> "pointer"
// phRegHandleOut : INT_PTR* out -> "pointer"
// pfnCallbackIn : PFN_AUTHENTICATION_CALLBACK_EX optional -> "pointer"
// pvParam : void* optional -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
uint32_t BluetoothRegisterForAuthenticationEx(
    void* pbtdiIn,
    intptr_t* phRegHandleOut,
    void* pfnCallbackIn,
    void* pvParam);
C, "BluetoothApis.dll");
// $ffi->BluetoothRegisterForAuthenticationEx(pbtdiIn, phRegHandleOut, pfnCallbackIn, pvParam);
// pbtdiIn : BLUETOOTH_DEVICE_INFO* optional
// phRegHandleOut : INT_PTR* out
// pfnCallbackIn : PFN_AUTHENTICATION_CALLBACK_EX optional
// pvParam : void* optional
// 構造体/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 BluetoothRegisterForAuthenticationEx(
        Pointer pbtdiIn,   // BLUETOOTH_DEVICE_INFO* optional
        LongByReference phRegHandleOut,   // INT_PTR* out
        Callback pfnCallbackIn,   // PFN_AUTHENTICATION_CALLBACK_EX optional
        Pointer pvParam   // void* optional
    );
}
@[Link("bluetoothapis")]
lib LibBluetoothApis
  fun BluetoothRegisterForAuthenticationEx = BluetoothRegisterForAuthenticationEx(
    pbtdiIn : BLUETOOTH_DEVICE_INFO*,   # BLUETOOTH_DEVICE_INFO* optional
    phRegHandleOut : LibC::SSizeT*,   # INT_PTR* out
    pfnCallbackIn : Void*,   # PFN_AUTHENTICATION_CALLBACK_EX optional
    pvParam : Void*   # void* optional
  ) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef BluetoothRegisterForAuthenticationExNative = Uint32 Function(Pointer<Void>, Pointer<IntPtr>, Pointer<Void>, Pointer<Void>);
typedef BluetoothRegisterForAuthenticationExDart = int Function(Pointer<Void>, Pointer<IntPtr>, Pointer<Void>, Pointer<Void>);
final BluetoothRegisterForAuthenticationEx = DynamicLibrary.open('BluetoothApis.dll')
    .lookupFunction<BluetoothRegisterForAuthenticationExNative, BluetoothRegisterForAuthenticationExDart>('BluetoothRegisterForAuthenticationEx');
// pbtdiIn : BLUETOOTH_DEVICE_INFO* optional -> Pointer<Void>
// phRegHandleOut : INT_PTR* out -> Pointer<IntPtr>
// pfnCallbackIn : PFN_AUTHENTICATION_CALLBACK_EX optional -> Pointer<Void>
// pvParam : void* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function BluetoothRegisterForAuthenticationEx(
  pbtdiIn: Pointer;   // BLUETOOTH_DEVICE_INFO* optional
  phRegHandleOut: Pointer;   // INT_PTR* out
  pfnCallbackIn: Pointer;   // PFN_AUTHENTICATION_CALLBACK_EX optional
  pvParam: Pointer   // void* optional
): DWORD; stdcall;
  external 'BluetoothApis.dll' name 'BluetoothRegisterForAuthenticationEx';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "BluetoothRegisterForAuthenticationEx"
  c_BluetoothRegisterForAuthenticationEx :: Ptr () -> Ptr CIntPtr -> Ptr () -> Ptr () -> IO Word32
-- pbtdiIn : BLUETOOTH_DEVICE_INFO* optional -> Ptr ()
-- phRegHandleOut : INT_PTR* out -> Ptr CIntPtr
-- pfnCallbackIn : PFN_AUTHENTICATION_CALLBACK_EX optional -> Ptr ()
-- pvParam : void* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let bluetoothregisterforauthenticationex =
  foreign "BluetoothRegisterForAuthenticationEx"
    ((ptr void) @-> (ptr intptr_t) @-> (ptr void) @-> (ptr void) @-> returning uint32_t)
(* pbtdiIn : BLUETOOTH_DEVICE_INFO* optional -> (ptr void) *)
(* phRegHandleOut : INT_PTR* out -> (ptr intptr_t) *)
(* pfnCallbackIn : PFN_AUTHENTICATION_CALLBACK_EX optional -> (ptr void) *)
(* pvParam : void* optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library bluetoothapis (t "BluetoothApis.dll"))
(cffi:use-foreign-library bluetoothapis)

(cffi:defcfun ("BluetoothRegisterForAuthenticationEx" bluetooth-register-for-authentication-ex :convention :stdcall) :uint32
  (pbtdi-in :pointer)   ; BLUETOOTH_DEVICE_INFO* optional
  (ph-reg-handle-out :pointer)   ; INT_PTR* out
  (pfn-callback-in :pointer)   ; PFN_AUTHENTICATION_CALLBACK_EX optional
  (pv-param :pointer))   ; void* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $BluetoothRegisterForAuthenticationEx = Win32::API::More->new('BluetoothApis',
    'DWORD BluetoothRegisterForAuthenticationEx(LPVOID pbtdiIn, LPVOID phRegHandleOut, LPVOID pfnCallbackIn, LPVOID pvParam)');
# my $ret = $BluetoothRegisterForAuthenticationEx->Call($pbtdiIn, $phRegHandleOut, $pfnCallbackIn, $pvParam);
# pbtdiIn : BLUETOOTH_DEVICE_INFO* optional -> LPVOID
# phRegHandleOut : INT_PTR* out -> LPVOID
# pfnCallbackIn : PFN_AUTHENTICATION_CALLBACK_EX optional -> LPVOID
# pvParam : void* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。

関連項目

類似 API
使用する型