ホーム › Devices.Bluetooth › BluetoothFindFirstDevice
BluetoothFindFirstDevice
関数条件に合う最初のBluetoothデバイスを検索する。
シグネチャ
// BluetoothApis.dll
#include <windows.h>
HBLUETOOTH_DEVICE_FIND BluetoothFindFirstDevice(
const BLUETOOTH_DEVICE_SEARCH_PARAMS* pbtsp,
BLUETOOTH_DEVICE_INFO* pbtdi
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pbtsp | BLUETOOTH_DEVICE_SEARCH_PARAMS* | in |
| pbtdi | BLUETOOTH_DEVICE_INFO* | inout |
戻り値の型: HBLUETOOTH_DEVICE_FIND
各言語での呼び出し定義
// BluetoothApis.dll
#include <windows.h>
HBLUETOOTH_DEVICE_FIND BluetoothFindFirstDevice(
const BLUETOOTH_DEVICE_SEARCH_PARAMS* pbtsp,
BLUETOOTH_DEVICE_INFO* pbtdi
);[DllImport("BluetoothApis.dll", SetLastError = true, ExactSpelling = true)]
static extern IntPtr BluetoothFindFirstDevice(
IntPtr pbtsp, // BLUETOOTH_DEVICE_SEARCH_PARAMS*
IntPtr pbtdi // BLUETOOTH_DEVICE_INFO* in/out
);<DllImport("BluetoothApis.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function BluetoothFindFirstDevice(
pbtsp As IntPtr, ' BLUETOOTH_DEVICE_SEARCH_PARAMS*
pbtdi As IntPtr ' BLUETOOTH_DEVICE_INFO* in/out
) As IntPtr
End Function' pbtsp : BLUETOOTH_DEVICE_SEARCH_PARAMS*
' pbtdi : BLUETOOTH_DEVICE_INFO* in/out
Declare PtrSafe Function BluetoothFindFirstDevice Lib "bluetoothapis" ( _
ByVal pbtsp As LongPtr, _
ByVal pbtdi As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
BluetoothFindFirstDevice = ctypes.windll.bluetoothapis.BluetoothFindFirstDevice
BluetoothFindFirstDevice.restype = ctypes.c_void_p
BluetoothFindFirstDevice.argtypes = [
ctypes.c_void_p, # pbtsp : BLUETOOTH_DEVICE_SEARCH_PARAMS*
ctypes.c_void_p, # pbtdi : BLUETOOTH_DEVICE_INFO* in/out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('BluetoothApis.dll')
BluetoothFindFirstDevice = Fiddle::Function.new(
lib['BluetoothFindFirstDevice'],
[
Fiddle::TYPE_VOIDP, # pbtsp : BLUETOOTH_DEVICE_SEARCH_PARAMS*
Fiddle::TYPE_VOIDP, # pbtdi : BLUETOOTH_DEVICE_INFO* in/out
],
Fiddle::TYPE_VOIDP)#[link(name = "bluetoothapis")]
extern "system" {
fn BluetoothFindFirstDevice(
pbtsp: *const BLUETOOTH_DEVICE_SEARCH_PARAMS, // BLUETOOTH_DEVICE_SEARCH_PARAMS*
pbtdi: *mut BLUETOOTH_DEVICE_INFO // BLUETOOTH_DEVICE_INFO* in/out
) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("BluetoothApis.dll", SetLastError = true)]
public static extern IntPtr BluetoothFindFirstDevice(IntPtr pbtsp, IntPtr pbtdi);
"@
$api = Add-Type -MemberDefinition $sig -Name 'BluetoothApis_BluetoothFindFirstDevice' -Namespace Win32 -PassThru
# $api::BluetoothFindFirstDevice(pbtsp, pbtdi)#uselib "BluetoothApis.dll"
#func global BluetoothFindFirstDevice "BluetoothFindFirstDevice" sptr, sptr
; BluetoothFindFirstDevice varptr(pbtsp), varptr(pbtdi) ; 戻り値は stat
; pbtsp : BLUETOOTH_DEVICE_SEARCH_PARAMS* -> "sptr"
; pbtdi : BLUETOOTH_DEVICE_INFO* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "BluetoothApis.dll" #cfunc global BluetoothFindFirstDevice "BluetoothFindFirstDevice" var, var ; res = BluetoothFindFirstDevice(pbtsp, pbtdi) ; pbtsp : BLUETOOTH_DEVICE_SEARCH_PARAMS* -> "var" ; pbtdi : BLUETOOTH_DEVICE_INFO* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "BluetoothApis.dll" #cfunc global BluetoothFindFirstDevice "BluetoothFindFirstDevice" sptr, sptr ; res = BluetoothFindFirstDevice(varptr(pbtsp), varptr(pbtdi)) ; pbtsp : BLUETOOTH_DEVICE_SEARCH_PARAMS* -> "sptr" ; pbtdi : BLUETOOTH_DEVICE_INFO* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HBLUETOOTH_DEVICE_FIND BluetoothFindFirstDevice(BLUETOOTH_DEVICE_SEARCH_PARAMS* pbtsp, BLUETOOTH_DEVICE_INFO* pbtdi) #uselib "BluetoothApis.dll" #cfunc global BluetoothFindFirstDevice "BluetoothFindFirstDevice" var, var ; res = BluetoothFindFirstDevice(pbtsp, pbtdi) ; pbtsp : BLUETOOTH_DEVICE_SEARCH_PARAMS* -> "var" ; pbtdi : BLUETOOTH_DEVICE_INFO* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HBLUETOOTH_DEVICE_FIND BluetoothFindFirstDevice(BLUETOOTH_DEVICE_SEARCH_PARAMS* pbtsp, BLUETOOTH_DEVICE_INFO* pbtdi) #uselib "BluetoothApis.dll" #cfunc global BluetoothFindFirstDevice "BluetoothFindFirstDevice" intptr, intptr ; res = BluetoothFindFirstDevice(varptr(pbtsp), varptr(pbtdi)) ; pbtsp : BLUETOOTH_DEVICE_SEARCH_PARAMS* -> "intptr" ; pbtdi : BLUETOOTH_DEVICE_INFO* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
bluetoothapis = windows.NewLazySystemDLL("BluetoothApis.dll")
procBluetoothFindFirstDevice = bluetoothapis.NewProc("BluetoothFindFirstDevice")
)
// pbtsp (BLUETOOTH_DEVICE_SEARCH_PARAMS*), pbtdi (BLUETOOTH_DEVICE_INFO* in/out)
r1, _, err := procBluetoothFindFirstDevice.Call(
uintptr(pbtsp),
uintptr(pbtdi),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HBLUETOOTH_DEVICE_FINDfunction BluetoothFindFirstDevice(
pbtsp: Pointer; // BLUETOOTH_DEVICE_SEARCH_PARAMS*
pbtdi: Pointer // BLUETOOTH_DEVICE_INFO* in/out
): THandle; stdcall;
external 'BluetoothApis.dll' name 'BluetoothFindFirstDevice';result := DllCall("BluetoothApis\BluetoothFindFirstDevice"
, "Ptr", pbtsp ; BLUETOOTH_DEVICE_SEARCH_PARAMS*
, "Ptr", pbtdi ; BLUETOOTH_DEVICE_INFO* in/out
, "Ptr") ; return: HBLUETOOTH_DEVICE_FIND●BluetoothFindFirstDevice(pbtsp, pbtdi) = DLL("BluetoothApis.dll", "void* BluetoothFindFirstDevice(void*, void*)")
# 呼び出し: BluetoothFindFirstDevice(pbtsp, pbtdi)
# pbtsp : BLUETOOTH_DEVICE_SEARCH_PARAMS* -> "void*"
# pbtdi : BLUETOOTH_DEVICE_INFO* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。