ホーム › Devices.Bluetooth › BluetoothRegisterForAuthentication
BluetoothRegisterForAuthentication
関数Bluetooth認証要求のコールバックを登録する。
シグネチャ
// BluetoothApis.dll
#include <windows.h>
DWORD BluetoothRegisterForAuthentication(
const BLUETOOTH_DEVICE_INFO* pbtdi, // optional
INT_PTR* phRegHandle,
PFN_AUTHENTICATION_CALLBACK pfnCallback, // optional
void* pvParam // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pbtdi | BLUETOOTH_DEVICE_INFO* | inoptional | 認証通知を受け取る対象デバイスの情報構造体ポインタ。NULLで全デバイス対象。 |
| phRegHandle | INT_PTR* | out | 登録ハンドルを受け取る出力ポインタ。登録解除時に使用。 |
| pfnCallback | PFN_AUTHENTICATION_CALLBACK | inoptional | 認証要求時に呼ばれるコールバック関数へのポインタ。 |
| pvParam | void* | inoptional | コールバックに渡される任意のパラメータポインタ。NULL可。 |
戻り値の型: 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 方式にも切替可。#uselib "BluetoothApis.dll" #cfunc global BluetoothRegisterForAuthentication "BluetoothRegisterForAuthentication" sptr, sptr, sptr, sptr ; res = BluetoothRegisterForAuthentication(varptr(pbtdi), varptr(phRegHandle), pfnCallback, pvParam) ; pbtdi : BLUETOOTH_DEVICE_INFO* optional -> "sptr" ; phRegHandle : INT_PTR* out -> "sptr" ; pfnCallback : PFN_AUTHENTICATION_CALLBACK optional -> "sptr" ; pvParam : void* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; DWORD BluetoothRegisterForAuthentication(BLUETOOTH_DEVICE_INFO* pbtdi, INT_PTR* phRegHandle, PFN_AUTHENTICATION_CALLBACK pfnCallback, void* pvParam) #uselib "BluetoothApis.dll" #cfunc global BluetoothRegisterForAuthentication "BluetoothRegisterForAuthentication" intptr, intptr, intptr, intptr ; res = BluetoothRegisterForAuthentication(varptr(pbtdi), varptr(phRegHandle), pfnCallback, pvParam) ; pbtdi : BLUETOOTH_DEVICE_INFO* optional -> "intptr" ; phRegHandle : INT_PTR* out -> "intptr" ; pfnCallback : PFN_AUTHENTICATION_CALLBACK optional -> "intptr" ; pvParam : void* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // DWORDfunction 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)。const std = @import("std");
extern "bluetoothapis" fn BluetoothRegisterForAuthentication(
pbtdi: [*c]BLUETOOTH_DEVICE_INFO, // BLUETOOTH_DEVICE_INFO* optional
phRegHandle: [*c]isize, // INT_PTR* out
pfnCallback: ?*anyopaque, // PFN_AUTHENTICATION_CALLBACK optional
pvParam: ?*anyopaque // void* optional
) callconv(std.os.windows.WINAPI) u32;proc BluetoothRegisterForAuthentication(
pbtdi: ptr BLUETOOTH_DEVICE_INFO, # BLUETOOTH_DEVICE_INFO* optional
phRegHandle: ptr int, # INT_PTR* out
pfnCallback: pointer, # PFN_AUTHENTICATION_CALLBACK optional
pvParam: pointer # void* optional
): uint32 {.importc: "BluetoothRegisterForAuthentication", stdcall, dynlib: "BluetoothApis.dll".}pragma(lib, "bluetoothapis");
extern(Windows)
uint BluetoothRegisterForAuthentication(
BLUETOOTH_DEVICE_INFO* pbtdi, // BLUETOOTH_DEVICE_INFO* optional
ptrdiff_t* phRegHandle, // INT_PTR* out
void* pfnCallback, // PFN_AUTHENTICATION_CALLBACK optional
void* pvParam // void* optional
);ccall((:BluetoothRegisterForAuthentication, "BluetoothApis.dll"), stdcall, UInt32,
(Ptr{BLUETOOTH_DEVICE_INFO}, Ptr{Int}, Ptr{Cvoid}, Ptr{Cvoid}),
pbtdi, phRegHandle, pfnCallback, pvParam)
# pbtdi : BLUETOOTH_DEVICE_INFO* optional -> Ptr{BLUETOOTH_DEVICE_INFO}
# phRegHandle : INT_PTR* out -> Ptr{Int}
# pfnCallback : PFN_AUTHENTICATION_CALLBACK optional -> Ptr{Cvoid}
# pvParam : void* optional -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t BluetoothRegisterForAuthentication(
void* pbtdi,
intptr_t* phRegHandle,
void* pfnCallback,
void* pvParam);
]]
local bluetoothapis = ffi.load("bluetoothapis")
-- bluetoothapis.BluetoothRegisterForAuthentication(pbtdi, phRegHandle, pfnCallback, pvParam)
-- pbtdi : BLUETOOTH_DEVICE_INFO* optional
-- phRegHandle : INT_PTR* out
-- pfnCallback : PFN_AUTHENTICATION_CALLBACK optional
-- pvParam : void* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('BluetoothApis.dll');
const BluetoothRegisterForAuthentication = lib.func('__stdcall', 'BluetoothRegisterForAuthentication', 'uint32_t', ['void *', 'intptr_t *', 'void *', 'void *']);
// BluetoothRegisterForAuthentication(pbtdi, phRegHandle, pfnCallback, pvParam)
// pbtdi : BLUETOOTH_DEVICE_INFO* optional -> 'void *'
// phRegHandle : INT_PTR* out -> 'intptr_t *'
// pfnCallback : PFN_AUTHENTICATION_CALLBACK optional -> 'void *'
// pvParam : void* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
// コールバック(関数ポインタ)は koffi.proto/koffi.register で型を定義して渡す(素の void* では JS 関数を渡せない)。const lib = Deno.dlopen("BluetoothApis.dll", {
BluetoothRegisterForAuthentication: { parameters: ["pointer", "pointer", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.BluetoothRegisterForAuthentication(pbtdi, phRegHandle, pfnCallback, pvParam)
// pbtdi : BLUETOOTH_DEVICE_INFO* optional -> "pointer"
// phRegHandle : INT_PTR* out -> "pointer"
// pfnCallback : PFN_AUTHENTICATION_CALLBACK optional -> "pointer"
// pvParam : void* optional -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t BluetoothRegisterForAuthentication(
void* pbtdi,
intptr_t* phRegHandle,
void* pfnCallback,
void* pvParam);
C, "BluetoothApis.dll");
// $ffi->BluetoothRegisterForAuthentication(pbtdi, phRegHandle, pfnCallback, pvParam);
// pbtdi : BLUETOOTH_DEVICE_INFO* optional
// phRegHandle : INT_PTR* out
// pfnCallback : PFN_AUTHENTICATION_CALLBACK 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 BluetoothRegisterForAuthentication(
Pointer pbtdi, // BLUETOOTH_DEVICE_INFO* optional
LongByReference phRegHandle, // INT_PTR* out
Callback pfnCallback, // PFN_AUTHENTICATION_CALLBACK optional
Pointer pvParam // void* optional
);
}@[Link("bluetoothapis")]
lib LibBluetoothApis
fun BluetoothRegisterForAuthentication = BluetoothRegisterForAuthentication(
pbtdi : BLUETOOTH_DEVICE_INFO*, # BLUETOOTH_DEVICE_INFO* optional
phRegHandle : LibC::SSizeT*, # INT_PTR* out
pfnCallback : Void*, # PFN_AUTHENTICATION_CALLBACK 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 BluetoothRegisterForAuthenticationNative = Uint32 Function(Pointer<Void>, Pointer<IntPtr>, Pointer<Void>, Pointer<Void>);
typedef BluetoothRegisterForAuthenticationDart = int Function(Pointer<Void>, Pointer<IntPtr>, Pointer<Void>, Pointer<Void>);
final BluetoothRegisterForAuthentication = DynamicLibrary.open('BluetoothApis.dll')
.lookupFunction<BluetoothRegisterForAuthenticationNative, BluetoothRegisterForAuthenticationDart>('BluetoothRegisterForAuthentication');
// pbtdi : BLUETOOTH_DEVICE_INFO* optional -> Pointer<Void>
// phRegHandle : INT_PTR* out -> Pointer<IntPtr>
// pfnCallback : PFN_AUTHENTICATION_CALLBACK optional -> Pointer<Void>
// pvParam : void* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "BluetoothRegisterForAuthentication"
c_BluetoothRegisterForAuthentication :: Ptr () -> Ptr CIntPtr -> Ptr () -> Ptr () -> IO Word32
-- pbtdi : BLUETOOTH_DEVICE_INFO* optional -> Ptr ()
-- phRegHandle : INT_PTR* out -> Ptr CIntPtr
-- pfnCallback : PFN_AUTHENTICATION_CALLBACK optional -> Ptr ()
-- pvParam : void* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let bluetoothregisterforauthentication =
foreign "BluetoothRegisterForAuthentication"
((ptr void) @-> (ptr intptr_t) @-> (ptr void) @-> (ptr void) @-> returning uint32_t)
(* pbtdi : BLUETOOTH_DEVICE_INFO* optional -> (ptr void) *)
(* phRegHandle : INT_PTR* out -> (ptr intptr_t) *)
(* pfnCallback : PFN_AUTHENTICATION_CALLBACK 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 ("BluetoothRegisterForAuthentication" bluetooth-register-for-authentication :convention :stdcall) :uint32
(pbtdi :pointer) ; BLUETOOTH_DEVICE_INFO* optional
(ph-reg-handle :pointer) ; INT_PTR* out
(pfn-callback :pointer) ; PFN_AUTHENTICATION_CALLBACK optional
(pv-param :pointer)) ; void* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $BluetoothRegisterForAuthentication = Win32::API::More->new('BluetoothApis',
'DWORD BluetoothRegisterForAuthentication(LPVOID pbtdi, LPVOID phRegHandle, LPVOID pfnCallback, LPVOID pvParam)');
# my $ret = $BluetoothRegisterForAuthentication->Call($pbtdi, $phRegHandle, $pfnCallback, $pvParam);
# pbtdi : BLUETOOTH_DEVICE_INFO* optional -> LPVOID
# phRegHandle : INT_PTR* out -> LPVOID
# pfnCallback : PFN_AUTHENTICATION_CALLBACK optional -> LPVOID
# pvParam : void* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# コールバック(関数ポインタ)は Perl sub を直接渡せません。Win32::API::Callback を使用してください。関連項目
類似 API
- f BluetoothRegisterForAuthenticationEx — 拡張版のBluetooth認証要求コールバックを登録する。