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

BluetoothFindNextDevice

関数
次のBluetoothデバイスの情報を検索する。
DLLBluetoothApis.dll呼出規約winapiSetLastErrorあり対応OSWindows Vista 以降

シグネチャ

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

BOOL BluetoothFindNextDevice(
    HBLUETOOTH_DEVICE_FIND hFind,
    BLUETOOTH_DEVICE_INFO* pbtdi
);

パラメーター

名前方向
hFindHBLUETOOTH_DEVICE_FINDin
pbtdiBLUETOOTH_DEVICE_INFO*inout

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL BluetoothFindNextDevice(
    HBLUETOOTH_DEVICE_FIND hFind,
    BLUETOOTH_DEVICE_INFO* pbtdi
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("BluetoothApis.dll", SetLastError = true, ExactSpelling = true)]
static extern bool BluetoothFindNextDevice(
    IntPtr hFind,   // HBLUETOOTH_DEVICE_FIND
    IntPtr pbtdi   // BLUETOOTH_DEVICE_INFO* in/out
);
<DllImport("BluetoothApis.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function BluetoothFindNextDevice(
    hFind As IntPtr,   ' HBLUETOOTH_DEVICE_FIND
    pbtdi As IntPtr   ' BLUETOOTH_DEVICE_INFO* in/out
) As Boolean
End Function
' hFind : HBLUETOOTH_DEVICE_FIND
' pbtdi : BLUETOOTH_DEVICE_INFO* in/out
Declare PtrSafe Function BluetoothFindNextDevice Lib "bluetoothapis" ( _
    ByVal hFind As LongPtr, _
    ByVal pbtdi As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

BluetoothFindNextDevice = ctypes.windll.bluetoothapis.BluetoothFindNextDevice
BluetoothFindNextDevice.restype = wintypes.BOOL
BluetoothFindNextDevice.argtypes = [
    wintypes.HANDLE,  # hFind : HBLUETOOTH_DEVICE_FIND
    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')
BluetoothFindNextDevice = Fiddle::Function.new(
  lib['BluetoothFindNextDevice'],
  [
    Fiddle::TYPE_VOIDP,  # hFind : HBLUETOOTH_DEVICE_FIND
    Fiddle::TYPE_VOIDP,  # pbtdi : BLUETOOTH_DEVICE_INFO* in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "bluetoothapis")]
extern "system" {
    fn BluetoothFindNextDevice(
        hFind: *mut core::ffi::c_void,  // HBLUETOOTH_DEVICE_FIND
        pbtdi: *mut BLUETOOTH_DEVICE_INFO  // BLUETOOTH_DEVICE_INFO* in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("BluetoothApis.dll", SetLastError = true)]
public static extern bool BluetoothFindNextDevice(IntPtr hFind, IntPtr pbtdi);
"@
$api = Add-Type -MemberDefinition $sig -Name 'BluetoothApis_BluetoothFindNextDevice' -Namespace Win32 -PassThru
# $api::BluetoothFindNextDevice(hFind, pbtdi)
#uselib "BluetoothApis.dll"
#func global BluetoothFindNextDevice "BluetoothFindNextDevice" sptr, sptr
; BluetoothFindNextDevice hFind, varptr(pbtdi)   ; 戻り値は stat
; hFind : HBLUETOOTH_DEVICE_FIND -> "sptr"
; pbtdi : BLUETOOTH_DEVICE_INFO* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "BluetoothApis.dll"
#cfunc global BluetoothFindNextDevice "BluetoothFindNextDevice" sptr, var
; res = BluetoothFindNextDevice(hFind, pbtdi)
; hFind : HBLUETOOTH_DEVICE_FIND -> "sptr"
; pbtdi : BLUETOOTH_DEVICE_INFO* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL BluetoothFindNextDevice(HBLUETOOTH_DEVICE_FIND hFind, BLUETOOTH_DEVICE_INFO* pbtdi)
#uselib "BluetoothApis.dll"
#cfunc global BluetoothFindNextDevice "BluetoothFindNextDevice" intptr, var
; res = BluetoothFindNextDevice(hFind, pbtdi)
; hFind : HBLUETOOTH_DEVICE_FIND -> "intptr"
; pbtdi : BLUETOOTH_DEVICE_INFO* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	bluetoothapis = windows.NewLazySystemDLL("BluetoothApis.dll")
	procBluetoothFindNextDevice = bluetoothapis.NewProc("BluetoothFindNextDevice")
)

// hFind (HBLUETOOTH_DEVICE_FIND), pbtdi (BLUETOOTH_DEVICE_INFO* in/out)
r1, _, err := procBluetoothFindNextDevice.Call(
	uintptr(hFind),
	uintptr(pbtdi),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function BluetoothFindNextDevice(
  hFind: THandle;   // HBLUETOOTH_DEVICE_FIND
  pbtdi: Pointer   // BLUETOOTH_DEVICE_INFO* in/out
): BOOL; stdcall;
  external 'BluetoothApis.dll' name 'BluetoothFindNextDevice';
result := DllCall("BluetoothApis\BluetoothFindNextDevice"
    , "Ptr", hFind   ; HBLUETOOTH_DEVICE_FIND
    , "Ptr", pbtdi   ; BLUETOOTH_DEVICE_INFO* in/out
    , "Int")   ; return: BOOL
●BluetoothFindNextDevice(hFind, pbtdi) = DLL("BluetoothApis.dll", "bool BluetoothFindNextDevice(void*, void*)")
# 呼び出し: BluetoothFindNextDevice(hFind, pbtdi)
# hFind : HBLUETOOTH_DEVICE_FIND -> "void*"
# pbtdi : BLUETOOTH_DEVICE_INFO* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。