次の方法で共有


BthNsSetService (Compact 2013)

3/26/2014

This function adds, updates, or removes service records from the local Service Discovery Protocol (SDP) database.

Syntax

INT BthNsSetService(
  LPWSAQUERYSET pSet,
  WSAESETSERVICEOP op,
  DWORD dwFlags
);

Parameters

  • pSet
    [in] Pointer to the service information for registration or deregistration.
  • op
    [in] Value to set to RNRSERVICE_REGISTER.
  • dwFlags
    [in] Flag to set to zero.

Return Value

If the operation is successful, the return value is zero (ERROR_SUCCESS). Otherwise, the value SOCKET_ERROR is returned. The following table shows possible error codes for the last error, if SOCKET_ERROR is set.

Error code

Description

WSASERVICE_NOT_FOUND

SDP is not running.

WSAEINVAL

The parameter is invalid.

WSA_NOT_ENOUGH_MEMORY

Memory is insufficient.

Remarks

Note

To preserve Win32 compatibility, consider using the Winsock equivalent of this function, WSASetService.

Servers use BthNsSetService to register specific service information with SDP. The following table shows the members of the WSAQUERYSET structure that are associated with values in the SDP record.

Member

Submember

Description

pSet

dwSize

sizeof(WSAQUERYSET)

 

lpszServiceInstanceName

Not supported in Windows Embedded Compact.

Set to 0.

 

lpServiceClassId

Not supported in Windows Embedded Compact.

Set to 0.

 

dwNameSpace

NS_BTH.

 

dwNumberOfCsAddrs

Not supported in Windows Embedded Compact.

Set to 0.

 

IpcsaBuffer

Not supported in Windows Embedded Compact.

Set to 0.

 

lpBlob

Points to a BTHNS_SETBLOB structure that contains information about the service to add.

 

All other WSAQUERYSET members are ignored.

 

op

 

RNRSERVICE_REGISTER.

dwFlags

 

Equal to 0 (clear).

BthNsSetService can be used to update an existing SDP record with new information. The call parameters are the same as in the initial record registration. The following table shows the exceptions.

Member

Submember

Description

pSet

lpBlob

BTHNS_SETBLOB structure that contains the service record handle.

The service record handle identifies the record that will be modified. Any differences between the existing SD record and the passed-in SD record are applied to match the passed-in record.

Attributes can be added, changed, or deleted, as long as the resulting record is legal according to SDP.

Changes that could result in an invalid record cause this function to return an error. If an error is returned, the existing SDP record remains unchanged.

This function can be used to delete existing SDP records. The following table shows the fields of the WSAQUERYSET structure.

Field

Subfield

Description

pSet

dwSize

sizeof(WSAQUERYSET)

 

dwNameSpace

NS_BTH

 

lpBlob

BTHNS_SETBLOB structure that contains the service-record handle

 

All other fields are ignored.

 

op

 

RNRSERVICE_DELETE

dwControlFlags

 

0 (clear)

Requirements

Header

bt_api.h

Library

Btdrt.lib

See Also

Reference

Bluetooth API Service Discovery Functions