如何搜索蓝牙驱动器的服务?

weacer 2006-05-29 05:47:26
首先搜索周围的蓝牙设备,然后查找搜索到的设备上的服务,比如,我搜索到附近一台v3手机,那么我如何知道v3手机上有什么服务可以提供?谢谢

#region Using directives

using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using InTheHand.Net.Bluetooth;
using InTheHand.Net.Sockets;
using InTheHand.Net;
using InTheHand.IO;
#endregion

namespace DeviceApplication1
{
/// <summary>
/// 窗体的摘要描述。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private ComboBox comboBox1;
/// <summary>
/// 窗体的主菜单。
/// </summary>
private System.Windows.Forms.MainMenu mainMenu1;

public Form1()
{
InitializeComponent();

//打开蓝牙设备
BluetoothRadio.PrimaryRadio.Mode = RadioMode.Connectable;

//新建一个bluetooth Client
BluetoothClient BC = new BluetoothClient();

//查找附近的蓝牙设备
BluetoothDeviceInfo[] arr = BC.DiscoverDevices(12);

foreach (BluetoothDeviceInfo b in arr)
{
this.comboBox1.Items.Clear();
this.comboBox1.Items.Add("--------");
this.comboBox1.Items.Add(b.DeviceName);
this.comboBox1.Items.Add("1." + b.ClassOfDevice);
this.comboBox1.Items.Add("2." + b.Connected);
this.comboBox1.Items.Add("3." + b.DeviceAddress);

System.Guid[] gui = b.InstalledServices;
this.comboBox1.Items.Add("4." + b.InstalledServices + gui.Length);
this.comboBox1.Items.Add("5." + b.LastSeen);
this.comboBox1.Items.Add("6." + b.LastUsed);
this.comboBox1.Items.Add("7." + b.Remembered);
this.comboBox1.Items.Add("--------");
this.comboBox1.SelectedIndex = 1;
}
//关闭蓝牙
BluetoothRadio.PrimaryRadio.Mode = RadioMode.PowerOff;
}

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
}

#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.comboBox1 = new System.Windows.Forms.ComboBox();
//
// comboBox1
//
this.comboBox1.Location = new System.Drawing.Point(3, 3);
this.comboBox1.Size = new System.Drawing.Size(170, 24);
//
// Form1
//
this.ClientSize = new System.Drawing.Size(176, 180);
this.Controls.Add(this.comboBox1);
this.Menu = this.mainMenu1;
this.Text = "Form1";

}

#endregion

/// <summary>
/// 应用程序的主入口点。
/// </summary>
static void Main()
{
Application.Run(new Form1());
}

}
}

...全文
730 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
LeiMZ 2006-08-18
  • 打赏
  • 举报
回复
你的InTheHand.Net.Bluetooth是那里来的 自己写的吗
Yuna_2z 2006-05-30
  • 打赏
  • 举报
回复
mark
weacer 2006-05-30
  • 打赏
  • 举报
回复
晕死,怎么就没有人回答呢

110,500

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧