WinXP/MFC:蓝牙枚举:重置设备列表?

发布于 2024-12-10 12:41:13 字数 857 浏览 0 评论 0原文

我正在查看一组需要使用的蓝牙设备。它们有一组已知的 MAC 地址,因此我可以从枚举列表中挑选它们。我在让系统向我提供当前列表时遇到问题。

BLUETOOTH_RADIO_INFO radioInfo;
radioInfo.dwSize = sizeof(radioInfo);
HRESULT hr = ::BluetoothGetRadioInfo(hRadio, &radioInfo);

BLUETOOTH_DEVICE_SEARCH_PARAMS deviceSearchParams;
memset(&deviceSearchParams, 0, sizeof(deviceSearchParams));
deviceSearchParams.dwSize = sizeof(deviceSearchParams);
deviceSearchParams.fReturnAuthenticated = false;
deviceSearchParams.fReturnRemembered = false;
deviceSearchParams.fReturnUnknown = true;
deviceSearchParams.fReturnConnected = false;
deviceSearchParams.hRadio = hRadio;

HANDLE hDeviceFind = ::BluetoothFindFirstDevice(&deviceSearchParams, &deviceInfo); 

我循环浏览设备列表并挑选出已识别的设备。

看来我必须重新运行控制面板小程序才能刷新可发现的设备,否则我会得到似乎是“记住”的列表(而不是本地、未配对和打开的设备的实际列表) 。

建议?

使用XP/VC2008/MFC

Im looking at a group of Bluetooth devices that I need to work with. They have a known bank of MAC addresses so I can pick them out of the enumerated list. Im running into problems getting the system to provide me with a current list.

BLUETOOTH_RADIO_INFO radioInfo;
radioInfo.dwSize = sizeof(radioInfo);
HRESULT hr = ::BluetoothGetRadioInfo(hRadio, &radioInfo);

BLUETOOTH_DEVICE_SEARCH_PARAMS deviceSearchParams;
memset(&deviceSearchParams, 0, sizeof(deviceSearchParams));
deviceSearchParams.dwSize = sizeof(deviceSearchParams);
deviceSearchParams.fReturnAuthenticated = false;
deviceSearchParams.fReturnRemembered = false;
deviceSearchParams.fReturnUnknown = true;
deviceSearchParams.fReturnConnected = false;
deviceSearchParams.hRadio = hRadio;

HANDLE hDeviceFind = ::BluetoothFindFirstDevice(&deviceSearchParams, &deviceInfo); 

I loop through the device list and pick out the recognized units.

It seems that I have to rerun the control panel applet in order to refresh the discoverable devices or else I get what appears to be a 'remembered' list (rather than the actual list of devices that are local, non-paired and turned on).

Suggestions?

Using XP/VC2008/MFC

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风柔一江水 2024-12-17 12:41:13

FWIW:如果您想重置列表,请使用以下代码:

WORD wVersionRequested = 0x202;
WSADATA m_data;

if ( ::WSAStartup(wVersionRequested, &m_data) == S_OK )
{
   WSAQUERYSET querySet;

   memset(&querySet, 0, sizeof(querySet));

   querySet.dwSize = sizeof(querySet);

   querySet.dwNameSpace = NS_BTH;

   HANDLE hLookup;
   DWORD flags = LUP_RETURN_NAME | LUP_CONTAINERS | LUP_RETURN_ADDR | LUP_FLUSHCACHE |      LUP_RETURN_TYPE | LUP_RETURN_BLOB | LUP_RES_SERVICE;

   int nResult = WSALookupServiceBegin(&querySet, flags, &hLookup);
   WSALookupServiceEnd(hLookup);
   WSACleanup();

   if( nResult != S_OK ) return FALSE; 
   else return TRUE;
}

return FALSE;

FWIW: If you want to reset the list, use this code:

WORD wVersionRequested = 0x202;
WSADATA m_data;

if ( ::WSAStartup(wVersionRequested, &m_data) == S_OK )
{
   WSAQUERYSET querySet;

   memset(&querySet, 0, sizeof(querySet));

   querySet.dwSize = sizeof(querySet);

   querySet.dwNameSpace = NS_BTH;

   HANDLE hLookup;
   DWORD flags = LUP_RETURN_NAME | LUP_CONTAINERS | LUP_RETURN_ADDR | LUP_FLUSHCACHE |      LUP_RETURN_TYPE | LUP_RETURN_BLOB | LUP_RES_SERVICE;

   int nResult = WSALookupServiceBegin(&querySet, flags, &hLookup);
   WSALookupServiceEnd(hLookup);
   WSACleanup();

   if( nResult != S_OK ) return FALSE; 
   else return TRUE;
}

return FALSE;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文