2014-08-03
0
个评论
收藏
我要投稿
C#
编程使笔记本蓝牙和外部设备蓝牙通信:
其实配对以后,蓝牙就被模拟成了一个端口,我们可以用最简单的端口通讯来收发信息。首先,在每次启动
时,需要连接端口:
[FORM
初始化时获取所有的
COM
口,并加入下拉列表
]
复制代码
1 public Form1()
2 {
3
InitializeComponent();
4
5
//Get all port list for selection
6
//
获得所有的端口列表,并显示在列表内
7
PortList.Items.Clear();
8
string[] Ports = SerialPort.GetPortNames();
9
10
for (int i = 0; i
11
{
12
string s = Ports[i].ToUpper();
13
Regex reg = new Regex("[^COM\\d]", RegexOptions.IgnoreCase |
RegexOptions.Multiline);
14
s = reg.Replace(s, ""