Share via


Managing the List of Paired Devices Using the Bluetooth Pairing Service

Windows CE 5.0 Not SupportedWindows Embedded NavReady 2009 Supported

10/16/2008

This topic describes how to manage the list of paired devices using the Bluetooth Pairing Service.

Getting the Paired Device List

Each paired device in the list is represented with a PAIREDDEVICEINFO structure. To start working with the paired device list, Windows Embedded CE calls GetBTDeviceList, specifying the Bluetooth profile that the returned list of paired devices must support. For example, if a list of all the paired devices which support the Hands-Free Profile is desired, call GetBTDeviceList and specify nProfileId as "HandsFreeAudioGatewayServiceClassID_UUID16". An array of PAIREDDEVICEINFO structures (one representing each paired device in the specified list) will be returned to the pPairInfo empty array that is passed into this function.

For example:

DWORD   dwPaired = 0;
DWORD   dwErr = GetBTDeviceCount( NULL, FALSE, &dwPaired );
    if( ( dwErr == ERROR_SUCCESS ) && dwPaired )
    {
        PPAIREDDEVICEINFO   pPairInfo = new PAIREDDEVICEINFO[ dwPaired ];
        DWORD               dwBufSize = sizeof(PAIREDDEVICEINFO) * dwPaired;

        if( pPairInfo )
        {
            dwErr = GetBTDeviceList( NULL, FALSE, pPairInfo, &dwBufSize );

After GetBTDeviceList returns, the pPairInfo filled array can be used to access the paired device list. Each indexed member of the array provides a member, PAIREDDEVICEINFO.m_btAddr, which stores the Bluetooth device address of the paired device. This allows Windows Embedded CE to supply the Bluetooth device address of a particular device (for accessing and modifying the paired device record) through the pPairInfo array. For example:

pPairInfo[2].m_diDeviceInfo.m_btAddr

If you just need the paired device record for the most recently paired device, call GetLatestBTDeviceInfo to get a pPairInfo array containing one entry for the most recently paired device in the list.

Deleting a Device from the List

Prior to deleting a paired device from the list, be sure that it has been deactivated. Call IsBTDeviceActivated to check whether a paired device is activated. If activated, call DeActivateBTDevice to deactivate it.

To delete a paired device from the list in the registry, call DeleteBTDevice, passing in the Bluetooth device address. To delete all devices in the list, call DeleteBTDevice, passing in 0.

See Also

Concepts

Managing the List of Paired Devices

Other Resources

How to Create and Manage Bluetooth Pairing Relationships