Click to Rate and Give Feedback
MSDN
MSDN Library
Windows Development
Wireless Networking
Bluetooth
Bluetooth Reference
Bluetooth Functions
 BluetoothFindFirstDevice function
BluetoothFindFirstDevice function

Applies to: desktop apps only

The BluetoothFindFirstDevice function begins the enumeration Bluetooth devices.

Syntax

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

Parameters

pbtsp

Pointer to a BLUETOOTH_DEVICE_SEARCH_PARAMS structure. The dwSize member of the BLUETOOTH_DEVICE_SEARCH_PARAMS structure pointed to by pbtsp must match the size of the structure.

pbtdi

Pointer to a BLUETOOTH_DEVICE_INFO structure into which information about the first Bluetooth device found is placed. The dwSize member of the BLUETOOTH_DEVICE_INFO structure pointed to by pbtdi must match the size of the structure, or the call to the BluetoothFindFirstDevice function fails.

Return value

Returns a valid handle to the first Bluetooth device upon successful completion, and the pbtdi parameter points to information about the device. When this handle is no longer needed, it must be closed via the BluetoothFindDeviceClose.

Returns NULL upon failure. Call the GetLastError function for more information on the error. The following table describe common errors:

Return codeDescription
ERROR_INVALID_PARAMETER

The pbtsp or pbtdi parameter is NULL.

ERROR_REVISION_MISMATCH

The structure pointed to by pbtsp or pbtdi is not the correct size.

 

Requirements

Minimum supported client

Windows Vista, Windows XP with SP2

Minimum supported server

None supported

Header

BluetoothAPIs.h (include Bthsdpdef.h or BluetoothAPIs.h)

Library

Bthprops.lib

See also

BluetoothDisplayDeviceProperties
BluetoothFindNextDevice
BluetoothFindDeviceClose
BluetoothGetDeviceInfo
BluetoothRemoveDevice
BluetoothUpdateDeviceRecord
BLUETOOTH_DEVICE_INFO
BLUETOOTH_DEVICE_SEARCH_PARAMS

 

 

Send comments about this topic to Microsoft

Build date: 2/3/2012

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
More details      Carl Kenner ... Thomas Lee   |   Edit   |   Show History
This function only works on the Microsoft bluetooth stack. If you have BlueSoleil, Widcomm (on non-vista OS), or Toshiba bluetooth stacks, you need to use a seperate API.

Despite its name, this function doesn't return until the timeout has elapsed, and all the bluetooth devices have been found. So choose a sensible timeout value. The BluetoothFindNextDevice function just enumerates through the found devices, and BluetoothFindDeviceClose frees the memory used to remember the list.
When there are zero results...      Alan J. McFarlane   |   Edit   |   Show History

When there are zero items to return this function returns NULL and GetLastError returns:

259=0x103=ERROR_NO_MORE_ITEMS

Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker