次の方法で共有


BthSetLinkKey (Windows Embedded CE 6.0)

1/6/2010

This function stores the link key for the Bluetooth device.

Note

To preserve Win32 compatibility, consider using the Winsock equivalent of this function. To do so, pass SO_BTH_SET_LINK as the optname value in setsockopt.

Syntax

int BthSetLinkKey (
  BT_ADDR* pba,
  unsigned char key[16]
);

Parameters

  • pba
    [in] A pointer to the Bluetooth address.
  • key
    [in] Stores the link key for the Bluetooth device identified in pba. The active connection to the device is not necessary, nor is the presence of the Bluetooth controller.

Return Value

This function returns ERROR_SUCCESS when it completes successfully.

A return value of ERROR_SERVICE_NOT_ACTIVE indicates that the Bluetooth stack is not present.

Other standard error codes may be returned as appropriate.

Remarks

The link key is persisted in registry until BthRevokeLinkKey is called.

Typically, the Bluetooth stack manages link keys automatically, for example, it stores them when they are created. This function is useful primarily for backup purposes.

While link key is stored, it will be automatically supplied once the link key request is issued by the authentication mechanism. If the link key is incorrect, the renegotiation that involves the PIN is initiated by the Bluetooth adapter, and the PIN code may be requested from the user.

The link key length is 16 bytes. You cannot create link keys; they are generated by the Bluetooth hardware.

Requirements

Header bt_api.h
Library Btdrt.lib
Windows Embedded CE Windows CE .NET 4.2 and later

See Also

Reference

Bluetooth OS Functions
BthRevokeLinkKey

Other Resources

Bluetooth Application Development