The BluetoothAuthenticateDevice function sends an authentication request to a remote Bluetooth device.
DWORD BluetoothAuthenticateDevice( HWND hwndParent, HANDLE hRadio, BLUETOOTH_DEVICE_INFO *pbtbi, PWSTR pszPasskey, ULONG ulPasskeyLength );
A window to be the parent of the Authentication wizard. If set to NULL, the wizard is removed from the desktop.
A valid local radio handle, or NULL. If NULL, authentication is attempted on all local radios; if any radio succeeds, the function call succeeds.
A structure of type BLUETOOTH_DEVICE_INFO that contains the record of the Bluetooth device to be authenticated.
A Personal Identification Number (PIN) to be used for device authentication. If set to NULL, the user interface is displayed and the user must follow the authentication process provided in the user interface. If pszPasskey is not NULL, no user interface is displayed. If the passkey is not NULL, it must be a NULL-terminated string. For more information, see the Remarks section.
The size, in characters, of pszPasskey. The size of pszPasskey must be less than or equal to BLUETOOTH_MAX_PASSKEY_SIZE.
Returns ERROR_SUCCESS upon successful completion.
Common errors are listed in the following table.
||The user canceled the operation.|
||The device structure in the pbtdi parameter is not valid.|
||The device pointed to by pbtdi is already marked as authenticated.|
Some remote Bluetooth devices can only accept numeric passkeys. There is no way to identify which devices only accept numeric passkeys in advance.
The Bluetooth authentication process has two modes: Wizard mode and Transparent mode.
Wizard mode is started when pszPasskey is set to NULL, and the Bluetooth Connection Wizard is started. The user is prompted to enter a passkey as a step in the wizard, after which the authentication request is sent. The user interface displays whether the authentication attempt succeeds or fails, and provides the user with an opportunity to reattempt a failed authentication.
Transparent mode is started when pszPasskey is not NULL. In Transparent mode the authentication request is sent to the remote Bluetooth device without displaying any user interface. In Transparent mode, the Bluetooth status code is mapped to a Win32 error code; the following table lists this mapping information.
|Bluetooth status code||Win32 error code|
|Minimum supported client||Windows Vista, Windows XP with SP2 [desktop apps only]|
|Minimum supported server||None supported|
|Header||bluetoothapis.h (include Bthsdpdef.h, BluetoothAPIs.h)|