BluetoothFindFirstDevice 函式 (bluetoothapis.h)

BluetoothFindFirstDevice 函式會開始列舉藍牙裝置。

語法

HBLUETOOTH_DEVICE_FIND BluetoothFindFirstDevice(
  const BLUETOOTH_DEVICE_SEARCH_PARAMS *pbtsp,
  BLUETOOTH_DEVICE_INFO                *pbtdi
);

參數

pbtsp

BLUETOOTH_DEVICE_SEARCH_PARAMS 結構的指標。 pbtsp 所指向之BLUETOOTH_DEVICE_SEARCH_PARAMS結構的 dwSize 成員必須符合 結構的大小。

pbtdi

指向 BLUETOOTH_DEVICE_INFO 結構的指標,其中會放置第一個藍牙裝置的相關信息。 pbtdi 所指向之BLUETOOTH_DEVICE_INFO結構的 dwSize 成員必須符合結構的大小,否則 BluetoothFindFirstDevice 函式的呼叫會失敗。

傳回值

成功完成時,傳回第一個藍牙裝置的有效句柄,而 pbtdi 參數指向裝置的相關信息。 不再需要此句柄時,必須透過 BluetoothFindDeviceClose 關閉。

失敗時傳回 NULL 。 如需錯誤的詳細資訊,請呼叫 GetLastError 函式。 下表描述常見的錯誤:

傳回碼 Description
ERROR_INVALID_PARAMETER
pbtsppbtdi 參數為 NULL
ERROR_REVISION_MISMATCH
pbtsppbtdi 所指向的結構不是正確的大小。

備註

BluetoothFindFirstDevice 函式找不到藍牙低能源 (LE) 裝置。 若要存取藍牙 LE 裝置,請使用 Windows 執行階段 藍牙低能源 API。 適用於藍牙的 Windows 執行階段 API 可同時在 UWP 和傳統型應用程式中運作。

規格需求

需求
最低支援的用戶端 Windows Vista、Windows XP SP2 [僅限傳統型應用程式]
最低支援的伺服器 都不支援
目標平台 Windows
標頭 bluetoothapis.h (包括 Bthsdpdef.h、BluetoothAPIs.h)
程式庫 Bthprops.lib
Dll bthprops.cpl

另請參閱

BLUETOOTH_DEVICE_INFO

BLUETOOTH_DEVICE_SEARCH_PARAMS

BluetoothDisplayDeviceProperties

BluetoothFindDeviceClose

BluetoothFindNextDevice

BluetoothGetDeviceInfo

BluetoothRemoveDevice

BluetoothUpdateDeviceRecord