void ISdpService.AddAttribute(ushort id, DESC_TYPE dt, int valLen, byte[] val) { Debug.Assert(id != 0, "Can't add ServiceRecordHandle..."); SDP_RETURN_CODE ret = NativeMethods.SdpService_AddAttribute(m_pSdpService, id, dt, checked ((uint)valLen), val); if (ret != SDP_RETURN_CODE.OK) { throw WidcommSocketExceptions.Create_SDP_RETURN_CODE(ret, "AddAttribute"); } }
void ISdpService.AddRFCommProtocolDescriptor(byte scn) { Debug.Assert(scn >= BluetoothEndPoint.MinScn, ">=1"); Debug.Assert(scn <= BluetoothEndPoint.MaxScn, "<=30"); SDP_RETURN_CODE ret = NativeMethods.SdpService_AddRFCommProtocolDescriptor( m_pSdpService, scn); if (ret != SDP_RETURN_CODE.OK) { throw WidcommSocketExceptions.Create_SDP_RETURN_CODE(ret, "AddRFCommProtocolDescriptor"); } }
void ISdpService.AddServiceClassIdList(Guid serviceClass) { GCHandle h = GCHandle.Alloc(serviceClass, GCHandleType.Pinned); try { IntPtr pArray = h.AddrOfPinnedObject(); SDP_RETURN_CODE ret = NativeMethods.SdpService_AddServiceClassIdList( m_pSdpService, 1, pArray); if (ret != SDP_RETURN_CODE.OK) { throw WidcommSocketExceptions.Create_SDP_RETURN_CODE(ret, "AddServiceClassIdList"); } } finally { h.Free(); } }
void ISdpService.AddServiceClassIdList(IList <Guid> serviceClasses) { Guid[] serviceClassArray = new Guid[serviceClasses.Count]; serviceClasses.CopyTo(serviceClassArray, 0); GCHandle h = GCHandle.Alloc(serviceClassArray, GCHandleType.Pinned); try { IntPtr pArray = h.AddrOfPinnedObject(); SDP_RETURN_CODE ret = NativeMethods.SdpService_AddServiceClassIdList( m_pSdpService, serviceClassArray.Length, pArray); if (ret != SDP_RETURN_CODE.OK) { throw WidcommSocketExceptions.Create_SDP_RETURN_CODE(ret, "AddServiceClassIdList"); } } finally { h.Free(); } }
void ISdpService.AddServiceName(string serviceName) { IntPtr pServiceNameAscii = IntPtr.Zero; #if !NETCF // Don't need ANSI there (and CF doesn't support marshalling to ascii/ansi) pServiceNameAscii = Marshal.StringToHGlobalAnsi(serviceName); #endif try { SDP_RETURN_CODE ret = NativeMethods.SdpService_AddServiceName( m_pSdpService, serviceName, pServiceNameAscii); if (ret != SDP_RETURN_CODE.OK) { throw WidcommSocketExceptions.Create_SDP_RETURN_CODE(ret, "AddServiceName"); } } finally { if (pServiceNameAscii != IntPtr.Zero) { Marshal.FreeHGlobal(pServiceNameAscii); } } }