The BTH_SET_SERVICE structure provides service information for the specified Bluetooth service.


typedef struct _BTH_SET_SERVICE {
  PULONG pSdpVersion;
  HANDLE *pRecordHandle;
  ULONG  fCodService;
  ULONG  Reserved[5];
  ULONG  ulRecordLength;
  UCHAR  pRecord[1];



Version of the SDP. Clients set this member to BTH_SDP_VERSION.


Handle to the SDP record. Corresponds to SDP ServiceRecordHandle. Returned by the add record operations, and subsequently used to delete the record.


Class of device (COD) information. A 32-bit field of COD_SERVICE_* class of device bits associated with this SDP record. The system combines these bits with COD bits from other service records and system characteristics. The resulting class of device for the local radio is advertised when the radio is found during device inquiry. When the last SDP record associated with a particular service bit is deleted, that service bit is no longer reported in responses to future device inquiries.

The format and possible values for the COD field are defined in the Bluetooth Assigned Numbers 1.1 portion of the Bluetooth specification, Section 1.2. (This resource may not be available in some languages and countries.) Corresponding macros and definitions for COD_SERVICE_* bits used by Windows are defined in Bthdef.h. For more information about class of device (COD), see BTH_DEVICE_INFO.


Reserved. Must be set to zero.


Size, in bytes, of pRecord.


SDP record, as defined by the Bluetooth specification.


When using the BTH_SET_SERVICE structure to query services and devices using the WSASetService function and WSAQUERYSET and BLOB structures. The following values for BTH_SET_SERVICE members must be used.

For more information about class of device (COD), see the Bluetooth specification at

MemberRequired value
pSdpVersionPointer to ULONG version, which is changed whenever the binary format of SDP records change, affecting the format of the pRecord member. Set to BTH_SDP_VERSION for the client, and returned by the system.
pRecordHandleHandle to the SDP record; corresponds to SDP ServiceRecordHandle. Returned by the add record operations, and subsequently used to delete the record.
fOptionsAttributes defined by BTHNS_SET_FLAGS.
ulRecordLengthLength, in bytes, of the binary SDP record pointed to by pRecord.
pRecordPointer to a valid SDP record, in the format defined by the Bluetooth specification.


The pRecordHandle member must point to data that is null for new service registration. For service deletion, pRecordHandle must point to a valid handle. The pRecord member must contain the entire SD service record, as described in the Bluetooth specification. For RFCOMM protocol entries, the port number is the same as the port returned by the getsockname function call.

Bluetooth implements a one-to-one correlation between SDP records and server sockets. As such, there is no need for the SERVICE_MULTIPLE flag.


Minimum supported client

Windows Vista, Windows XP with SP2 [desktop apps only]

Minimum supported server

None supported



See also

Bluetooth and BLOB
Bluetooth and getsockname
Bluetooth and WSASetService



Community Additions