刚接触蓝牙开发,还不知道应该如何配置开发平台,下面的代码可以运行,但总是显式找不到蓝牙设备,急需帮助!先谢谢了!
(机器上有蓝牙适配器,用BlueSoleil测试可以连接到手机并传输文件,所有与蓝牙有关的服务均已开启)
安装了:Windows Platform SDK
导入了:irprops.lib
包含了头文件:bthdef.h,bluetoothapis.h
不过有一个文件不知道在哪里:Irprops.cpl
不知道是哪里出问题了或设置不对?(就差一点点就成功了)
- C/C++ code
#include <windows.h>#include <bthdef.h>#include <bluetoothapis.h>#include <conio.h>#include <iostream>using namespace std;int wmain(int argc, wchar_t** argv){ BLUETOOTH_DEVICE_SEARCH_PARAMS BluetoothSearchParams; BLUETOOTH_DEVICE_INFO BluetoothDeviceInfo; HBLUETOOTH_DEVICE_FIND hBluetoothDevice; ZeroMemory(&BluetoothSearchParams, sizeof(BluetoothSearchParams)); ZeroMemory(&BluetoothDeviceInfo, sizeof(BluetoothDeviceInfo)); BluetoothSearchParams.dwSize = sizeof(BLUETOOTH_DEVICE_SEARCH_PARAMS); BluetoothSearchParams.fReturnAuthenticated= true; BluetoothSearchParams.fReturnRemembered = true; BluetoothSearchParams.fReturnUnknown = true; BluetoothSearchParams.fReturnConnected = true; BluetoothSearchParams.fIssueInquiry = true; BluetoothSearchParams.cTimeoutMultiplier = 15; BluetoothSearchParams.hRadio = NULL; BluetoothDeviceInfo.dwSize = sizeof(BluetoothDeviceInfo); hBluetoothDevice = BluetoothFindFirstDevice(&BluetoothSearchParams, &BluetoothDeviceInfo); if (hBluetoothDevice != NULL) { // Handle the found device... // Continue enumerating Bluetooth devices... } else { cout << "Unable to find a Bluetooth device." << endl; } getch(); return 0;}
------解决方案--------------------------------------------------------
把BlueSoleil卸了再试试看!