资源简介
之前下载的BlueToothExc代码,文件不全,这是完整的代码,能运行成功
代码片段和文件信息
#include “StdAfx.h“
#include “BlueTooth.h“
CBlueTooth::CBlueTooth(void)
{
m_Ary_RemoteBthDevInfo.SetSize ( 0 10*sizeof(BLUETOOTH_DEVICE_INFO) );
m_Ary_LocalRadioInfo.SetSize ( 0 10*sizeof(t_LocalRadioInfo) );
}
CBlueTooth::~CBlueTooth(void)
{
RemoveAll_RemoteBthDevInfo ();
RemoveAllLocalRadio ();
}
//
// 用 Socket 函数搜索附近的蓝牙设备,成功时返回设备数,否则返回-1
//
int CBlueTooth::WSAScanNearbyBthDev ()
{
m_Ary_RemoteBthDevInfo.RemoveAll ();
WSAQUERYSET wsaq;
HANDLE hLookup;
union
{
CHAR buf[5000];
double __unused; // ensure proper alignment
};
LPWSAQUERYSET pwsaResults = (LPWSAQUERYSET) buf;
DWORD dwSize = sizeof(buf);
BOOL bHaveName;
ZeroMemory(&wsaq sizeof(wsaq));
wsaq.dwSize = sizeof(wsaq);
wsaq.dwNameSpace = NS_BTH;
wsaq.lpcsaBuffer = NULL;
if (ERROR_SUCCESS != WSALookupServiceBegin (&wsaq LUP_CONTAINERS &hLookup))
{
TRACE ( _T(“WSALookupServiceBegin failed\n“) );
return -1;
}
ZeroMemory(pwsaResults sizeof(WSAQUERYSET));
pwsaResults->dwSize = sizeof(WSAQUERYSET);
pwsaResults->dwNameSpace = NS_BTH;
pwsaResults->lpBlob = NULL;
while (ERROR_SUCCESS == WSALookupServiceNext (hLookup LUP_RETURN_NAME | LUP_RETURN_ADDR &dwSize pwsaResults))
{
ASSERT (pwsaResults->dwNumberOfCsAddrs == 1);
BTH_ADDR b = ((SOCKADDR_BTH *)pwsaResults->lpcsaBuffer->RemoteAddr.lpSockaddr)->btAddr;
bHaveName = pwsaResults->lpszServiceInstanceName && *(pwsaResults->lpszServiceInstanceName);
t_RemoteBthDevInfo RemoteBthDevInfo;
if ( bHaveName )
{
StringCchPrintf ( RemoteBthDevInfo.szName sizeof(RemoteBthDevInfo.szName) _T(“%s“)
pwsaResults->lpszServiceInstanceName );
}
RemoteBthDevInfo.Address.ullLong = b;
TRACE (L“%s ( %04x%08x )\n“ RemoteBthDevInfo.szName GET_NAP(b) GET_SAP(b) );
m_Ary_RemoteBthDevInfo.Add ( RemoteBthDevInfo );
}
WSALookupServiceEnd(hLookup);
return (int)m_Ary_RemoteBthDevInfo.GetSize();
}
BOOL AUTHENTICATION_CALLBACK (LPVOID pvParam PBLUETOOTH_DEVICE_INFO pDevice)
{
t_AUTHENTICATION_CALLBACK_Para *pAUTHENTICATION_CALLBACK_Para = (t_AUTHENTICATION_CALLBACK_Para*)pvParam;
if ( pAUTHENTICATION_CALLBACK_Para )
{
pDevice->fAuthenticated = TRUE;
DWORD result = BluetoothUpdateDeviceRecord ( pDevice );
ASSERT ( result == ERROR_SUCCESS );
result = BluetoothSendAuthenticationResponse ( pAUTHENTICATION_CALLBACK_Para->hRadio pDevice AUTHENTICATION_PASSKEY );
if ( result == ERROR_SUCCESS )
return TRUE;
}
return FALSE;
}
//
// 用蓝牙 APIs 搜索附近的蓝牙设备,成功时返回设备数,否则返回-1
//
int CBlueTooth::ScanNearbyBthDev (
HANDLE hRadio
BOOL fReturnAuthenticated/* = TRUE*/
BOOL fReturnRemembered/* = TRUE*/
BOOL fReturnUnknown/* = TRUE*/
BOOL fReturnConnected/* = TRUE*/
BOOL fIssueInquiry/* = FALSE*/
UCHAR cTimeoutMultiplier/* = 30*/
)
{
RemoveAll_RemoteBthDevInfo ();
CWaitCursor WaitCursor;
BLUETOOTH_DEVICE_INFO bdi = { sizeof(BLUETOOTH_DEVICE_INFO) };
BLUETOOTH_DEVICE_SEARCH_PARAMS
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 12846 2007-08-08 10:30 BlueToothExc_Plus原版\BlueTooth.cpp
文件 3923 2015-08-13 10:49 BlueToothExc_Plus原版\BlueTooth.h
文件 47920 2016-04-26 10:03 BlueToothExc_Plus原版\BlueToothExc.aps
文件 2407 2007-08-08 10:30 BlueToothExc_Plus原版\BlueToothExc.cpp
文件 579 2007-08-08 10:30 BlueToothExc_Plus原版\BlueToothExc.h
文件 4295680 2016-04-28 00:44 BlueToothExc_Plus原版\BlueToothExc.ncb
文件 9715 2016-04-27 03:41 BlueToothExc_Plus原版\BlueToothExc.rc
文件 56184832 2015-08-13 10:49 BlueToothExc_Plus原版\BlueToothExc.sdf
文件 889 2016-04-27 03:56 BlueToothExc_Plus原版\BlueToothExc.sln
文件 888 2007-08-08 10:30 BlueToothExc_Plus原版\BlueToothExc.sln.old
..A..H. 36864 2016-04-28 00:30 BlueToothExc_Plus原版\BlueToothExc.suo
..A..H. 19968 2010-03-27 03:26 BlueToothExc_Plus原版\BlueToothExc.suo.old
文件 6237 2016-04-27 03:51 BlueToothExc_Plus原版\BlueToothExc.vcproj
文件 6173 2007-08-12 13:17 BlueToothExc_Plus原版\BlueToothExc.vcproj.8.00.old
文件 1415 2016-04-28 00:38 BlueToothExc_Plus原版\BlueToothExc.vcproj.chenqi-PC.chenqi.user
文件 1415 2008-06-25 08:04 BlueToothExc_Plus原版\BlueToothExc.vcproj.CHRYS-T60.chrys.user
文件 1407 2016-04-26 10:02 BlueToothExc_Plus原版\BlueToothExc.vcproj.PETER.leno.user
文件 1427 2010-03-27 03:26 BlueToothExc_Plus原版\BlueToothExc.vcproj.XIAOFEI-C7D8CBB.pc.user
文件 1427 2010-03-26 09:28 BlueToothExc_Plus原版\BlueToothExc.vcproj.XIAOFEI-GUZ2EBI.pc.user
文件 8148 2015-08-13 09:53 BlueToothExc_Plus原版\BlueToothExc.vcxproj
文件 2849 2015-08-13 09:53 BlueToothExc_Plus原版\BlueToothExc.vcxproj.filters
文件 143 2015-08-13 09:53 BlueToothExc_Plus原版\BlueToothExc.vcxproj.user
文件 155065 2016-04-26 10:01 BlueToothExc_Plus原版\Debug\BlueTooth.obj
文件 2438656 2016-04-26 10:02 BlueToothExc_Plus原版\Debug\BlueToothExc.exe
文件 682 2016-04-26 10:02 BlueToothExc_Plus原版\Debug\BlueToothExc.exe.em
文件 748 2016-04-26 10:02 BlueToothExc_Plus原版\Debug\BlueToothExc.exe.em
文件 640 2016-04-26 10:02 BlueToothExc_Plus原版\Debug\BlueToothExc.exe.intermediate.manifest
文件 7354212 2016-04-26 10:02 BlueToothExc_Plus原版\Debug\BlueToothExc.ilk
文件 24985 2016-04-26 10:02 BlueToothExc_Plus原版\Debug\BlueToothExc.obj
文件 22675456 2016-04-26 10:01 BlueToothExc_Plus原版\Debug\BlueToothExc.pch
............此处省略58个文件信息
- 上一篇:特征提取与图像处理第二版pdf
- 下一篇:基于windows的蓝牙通信
相关资源
- 基于windows的蓝牙通信
- 泊松重建代码
- CSR BlueSuite 2.6.2.exe
- boost库开发范例大全
- 基于qt实现的minidraw画板程序
- 虚拟串口程序操作系统原理大作业
- VS2013做的推箱子含源码
- VS2013 做的简单的贪吃蛇含源码
- 多功能网络媒体播放器-Qt-demo
- 通用蓝牙串口调试工具
- 坦克大战可执行程序-windows
- Bluetooth 5.0协议+新特性
- 蓝牙通讯代码
- 炫彩气泡--win32实现透明不规则窗口
- amCap工具源码
- 基于opencv的三种人脸识别
- 个人防火墙
- B样条反求控制点绘制曲线
- cmake-3.15.0-rc3-win64-x64.msi
- 远程控制桌面源码
- 基于opencv的鱼眼相机标定和透视投影
- 记事本开发
- nrf51822蓝牙连接APP安卓源码
- 客户与服务器程序的同步与通信机制
- 三维点云的可视化
- 泊松曲面重建
- TI官方开发板资料
- 基于Qt实现的物流管理系统
- 编译原理第2版(中文)
- windows中苹果原装博通无线网卡驱动,
评论
共有 条评论