资源简介
C# wince 蓝牙控制、搜索设备、文件发送

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using InTheHand.Net;
using InTheHand.Net.Bluetooth;
using InTheHand.Net.Ports;
using InTheHand.Net.Sockets;
using System.Threading;
namespace NewHMIBth
{
public partial class MainFrm : Form
{
private BluetoothListener Listener;
private List clientList = new List();
private bool listening = true;
public MainFrm()
{
InitializeComponent();
btnSend.Enabled = false;
btnStop.Enabled =false;
}
private delegate void SafeWinFormsThreadDelegate(string msg);
private void WriteMsg(string msg)
{
SafeWinFormsThreadDelegate d = new SafeWinFormsThreadDelegate(UpdateUI);
Invoke(d new object[] { msg });
}
private void UpdateUI(string msg)
{
this.listBoxMsg.Items.Add(msg);
}
private void btnStart_Click(object sender EventArgs e)
{
BluetoothRadio radio = BluetoothRadio.PrimaryRadio;
if (radio == null)
{
UpdateUI(“没有发现蓝牙设备或者不支持蓝牙协议栈!“);
return;
}
radio.Mode = RadioMode.Discoverable;
Listener = new BluetoothListener(BluetoothService.SerialPort);
Listener.Start();
listening = true;
Thread ListenerThread = new Thread(ListenLoop);
ListenerThread.Start();
btnStop.Enabled = true;
btnStart.Enabled = false;
btnSend.Enabled = true;
UpdateUI(“蓝牙服务开始!“);
}
private void ListenLoop()
{
string dataToSend = “感谢您的蓝牙信息订阅\r\n“;
byte[] dataBuffer = System.Text.Encoding.Unicode.GetBytes(dataToSend);
while(listening)
{
try
{
BluetoothClient Client = Listener.AcceptBluetoothClient();
WriteMsg(“获得从“+Client.RemoteMachineName+“蓝牙信息订阅“);
clientList.Add(Client);
System.IO.Stream ns = Client.GetStream();
ns.Write(dataBuffer 0 dataBuffer.Length);
}
catch
{
break;
}
}
Listener.Stop();
}
private void btnSend_Click(object sender EventArgs e)
{
BroadLoop(this.txtMsg.Text);
}
private void BroadLoop(string Msg)
{
List tempClientList = new List();
string dataSend=“蓝牙发送的信息内容:“+Msg+“\r\n“;
Byte[] dataBuffer=System.Text.Encoding.Unicode.GetBytes(dataSend);
foreach
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 346 2010-02-13 10:24 Bluetooth\NewHMIBth\NewBthDeviceCab\Debug\CabWiz.log
文件 245542 2010-02-13 10:24 Bluetooth\NewHMIBth\NewBthDeviceCab\Debug\NewBthDeviceCab.CAB
文件 1826 2010-02-13 10:24 Bluetooth\NewHMIBth\NewBthDeviceCab\Debug\NewBthDeviceCab.inf
文件 15960 2010-02-13 10:24 Bluetooth\NewHMIBth\NewBthDeviceCab\NewBthDeviceCab.vddproj
文件 229888 2009-09-09 08:40 Bluetooth\NewHMIBth\NewHMIBth\bin\Debug\InTheHand.Net.Personal.dll
文件 13824 2010-03-28 19:28 Bluetooth\NewHMIBth\NewHMIBth\bin\Debug\NewHMIBth.exe
文件 28160 2010-03-28 19:28 Bluetooth\NewHMIBth\NewHMIBth\bin\Debug\NewHMIBth.pdb
文件 6392 2010-02-13 10:24 Bluetooth\NewHMIBth\NewHMIBth\MainFrm.cs
文件 11170 2010-02-13 10:24 Bluetooth\NewHMIBth\NewHMIBth\MainFrm.Designer.cs
文件 6298 2010-02-13 10:24 Bluetooth\NewHMIBth\NewHMIBth\MainFrm.resx
文件 4196 2009-12-05 14:21 Bluetooth\NewHMIBth\NewHMIBth\NewHMIBth.csproj
文件 198 2010-03-28 19:28 Bluetooth\NewHMIBth\NewHMIBth\NewHMIBth.csproj.user
文件 844 2010-02-13 10:24 Bluetooth\NewHMIBth\NewHMIBth\obj\Debug\NewHMIBth.csproj.GenerateResource.Cache
文件 13824 2010-03-28 19:28 Bluetooth\NewHMIBth\NewHMIBth\obj\Debug\NewHMIBth.exe
文件 180 2010-02-13 10:24 Bluetooth\NewHMIBth\NewHMIBth\obj\Debug\NewHMIBth.MainFrm.resources
文件 28160 2010-03-28 19:28 Bluetooth\NewHMIBth\NewHMIBth\obj\Debug\NewHMIBth.pdb
文件 180 2009-12-05 21:48 Bluetooth\NewHMIBth\NewHMIBth\obj\Debug\NewHMIBth.Properties.Resources.resources
文件 13609 2010-04-07 11:04 Bluetooth\NewHMIBth\NewHMIBth\obj\Debug\ResolveAssemblyReference.cache
文件 284 2010-02-13 10:24 Bluetooth\NewHMIBth\NewHMIBth\obj\NewHMIBth.csproj.FileList.txt
文件 796 2010-03-28 19:28 Bluetooth\NewHMIBth\NewHMIBth\obj\NewHMIBth.csproj.FileListAbsolute.txt
文件 356 2009-12-05 13:17 Bluetooth\NewHMIBth\NewHMIBth\Program.cs
文件 1147 2009-12-05 13:15 Bluetooth\NewHMIBth\NewHMIBth\Properties\AssemblyInfo.cs
文件 2355 2009-12-05 13:15 Bluetooth\NewHMIBth\NewHMIBth\Properties\Resources.Designer.cs
文件 5618 2009-12-05 13:15 Bluetooth\NewHMIBth\NewHMIBth\Properties\Resources.resx
文件 1402 2009-12-05 15:30 Bluetooth\NewHMIBth\NewHMIBth.sln
..A..H. 20480 2010-06-17 09:28 Bluetooth\NewHMIBth\NewHMIBth.suo
文件 139264 2009-10-01 22:40 Bluetooth\NewPCBth\NewPCBth\bin\Debug\InTheHand.Net.Personal.dll
文件 5632 2005-12-08 14:51 Bluetooth\NewPCBth\NewPCBth\bin\Debug\NewPCBth.vshost.exe
..A.SH. 9728 2010-03-28 19:34 Bluetooth\NewPCBth\NewPCBth\bin\Debug\Thumbs.db
文件 7313 2010-02-13 10:31 Bluetooth\NewPCBth\NewPCBth\Form1.cs
............此处省略43个文件信息
- 上一篇:C# 透明 背景 的垂直 Label控件
- 下一篇:C#开发银行叫号系统
相关资源
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
- 基于c#的实验室设备管理系统621530
- C# 使用ListView控件实现图片浏览器(源
- C#简单窗体聊天程序
- C#指纹识别系统程序 报告
- c# 高校档案信息管理系统
评论
共有 条评论