BluetoothSetServiceState function (bluetoothapis.h)

The BluetoothSetServiceState function enables or disables services for a Bluetooth device.

Syntax

DWORD BluetoothSetServiceState(
  HANDLE                      hRadio,
  const BLUETOOTH_DEVICE_INFO *pbtdi,
  const GUID                  *pGuidService,
  DWORD                       dwServiceFlags
);

Parameters

hRadio

A handle of the local Bluetooth radio.

pbtdi

A pointer to a BLUETOOTH_DEVICE_INFO structure. Must be a previously found radio address.

pGuidService

A pointer to the service GUID on the remote device.

dwServiceFlags

The flags that adjust the service. To disable the service, set to BLUETOOTH_SERVICE_DISABLE; to enable the service, set to BLUETOOTH_SERVICE_ENABLE.

Return value

Returns ERROR_SUCCESS upon successful completion. The following table lists common errors.

Return code Description
ERROR_INVALID_PARAMETER
The dwServiceFlags are not valid.
ERROR_SERVICE_DOES_NOT_EXIST
The GUID specified in pGuidService is not supported.
E_INVALIDARG
dwServiceFlags is set to BLUETOOTH_SERVICE_DISABLE and the service is already disabled, or dwServiceFlags is set to BLUETOOTH_SERVICE_ENABLE and the service is already enabled.

Remarks

Windows maintains a mapping of service Globally Unique Identifiers (GUIDs) to supported drivers for Bluetooth-enabled devices. Enabling a service installs the corresponding device driver and disabling a service removes the corresponding device driver. If a non-supported service is enabled, a driver is not installed.

Requirements

Requirement Value
Minimum supported client Windows Vista, Windows XP with SP2 [desktop apps only]
Minimum supported server None supported
Target Platform Windows
Header bluetoothapis.h (include Bthsdpdef.h, BluetoothAPIs.h)
Library Bthprops.lib
DLL bthprops.cpl

See also

BLUETOOTH_DEVICE_INFO

BLUETOOTH_DEVICE_SEARCH_PARAMS

BluetoothDisplayDeviceProperties

BluetoothFindDeviceClose

BluetoothFindFirstDevice

BluetoothFindNextDevice

BluetoothGetDeviceInfo

BluetoothRemoveDevice