Skip to content

Latest commit

 

History

History
181 lines (144 loc) · 5.67 KB

nf-bluetoothapis-bluetoothauthenticatedeviceex.md

File metadata and controls

181 lines (144 loc) · 5.67 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:bluetoothapis.BluetoothAuthenticateDeviceEx
BluetoothAuthenticateDeviceEx function (bluetoothapis.h)
The BluetoothAuthenticateDeviceEx function sends an authentication request to a remote Bluetooth device.
BluetoothAuthenticateDeviceEx
BluetoothAuthenticateDeviceEx function [Bluetooth]
bluetooth.bluetoothauthenticatedeviceex
bluetoothapis/BluetoothAuthenticateDeviceEx
bluetooth\bluetoothauthenticatedeviceex.htm
bluetooth
948bf14c-9661-4fe9-b082-009afd867baf
12/05/2018
BluetoothAuthenticateDeviceEx, BluetoothAuthenticateDeviceEx function [Bluetooth], bluetooth.bluetoothauthenticatedeviceex, bluetoothapis/BluetoothAuthenticateDeviceEx
bluetoothapis.h
Bthsdpdef.h, BluetoothAPIs.h
Windows
Windows XP with SP2 [desktop apps only]
None supported
Bthprops.lib
bthprops.cpl
Windows
19H1
BluetoothAuthenticateDeviceEx
bluetoothapis/BluetoothAuthenticateDeviceEx
c++
APIRef
kbSyntax
DllExport
bthprops.cpl
BluetoothAuthenticateDeviceEx

BluetoothAuthenticateDeviceEx function

-description

The BluetoothAuthenticateDeviceEx function sends an authentication request to a remote Bluetooth device. Additionally, this function allows for out-of-band data to be passed into the function call for the device being authenticated.

Note  This API is supported in Windows Vista SP2 and Windows 7.
 

-parameters

-param hwndParentIn [in, optional]

The window to parent the authentication wizard. If NULL, the wizard will be parented off the desktop.

-param hRadioIn [in, optional]

A valid local radio handle or NULL. If NULL, then all radios will be tried. If any of the radios succeed, then the call will succeed.

-param pbtdiInout [in, out]

A pointer to a BLUETOOTH_DEVICE_INFO structure describing the device being authenticated.

-param pbtOobData [in, optional]

Pointer to device specific out-of-band data to be provided with this API call. If NULL, then a UI is displayed to continue the authentication process. If not NULL, no UI is displayed.

Note  If a callback is registered using BluetoothRegisterForAuthenticationEx, then a UI will not be displayed.
 

-param authenticationRequirement [in]

An BLUETOOTH_AUTHENTICATION_REQUIREMENTS value that specifies the protection required for authentication.

-returns

Returns ERROR_SUCCESS upon successful completion; returns the following error codes upon failure:

Return code Description
ERROR_CANCELLED
The user aborted the operation.
ERROR_INVALID_PARAMETER
The device structure specified in pbdti is invalid.
ERROR_NO_MORE_ITEMS
The device in pbtdi is already been marked as authenticated.

-remarks

The BLUETOOTH_DEVICE_INFO structure specified by pbtdilInOut must contain the address of a device to authenticate. If the value of pbtOobData is not NULL, an attempt will be made to authenticate the remote device with the provided out-of-band data.

For all other types of authentication, the caller should register an authentication callback using BluetoothRegisterForAuthenticationEx and then respond to the relevant authentication method using BluetoothSendAuthenticationResponseEx.

Examples

In the following example code a device has been found and an authentication request is sent using BluetoothAuthenticateDeviceEx.

PBLUETOOTH_DEVICE_INFO pDeviceInfo; 
HRESULT status;
HANDLE hEvent = NULL;

HRESULT WINAPI AuthenticateService(){

	status = BluetoothAuthenticateDeviceEx( NULL,
					        NULL,
					        pDeviceInfo,
					        NULL,
					        MITMProtectionNotRequired );

	if ( ERROR_INVALID_PARAMETER == status ) {
		// goto Cleanup;
		// ...
		// Take cleanup action here,
		// ...
	}
//
// Wait for the Authentication callback to return before trying to unregister the handle
// Use an infinite timeout since the handle to the function that sets the event is being
// deleted
//

	if ( WAIT_FAILED == WaitForSingleObject(hEvent, INFINITE) ) {
        	status = GetLastError();
        	// goto Cleanup;
		// ...
		// Take cleanup action here,
		// ...
	}

      return status;
}

-see-also

BluetoothAuthenticateDevice