|
开发环境为EVC4.0+EVCSp4+PPC 2003,想要实现在WinCE 5.0平台上的,搜索蓝牙设备并返回设备号的功能。由于时间机器紧张,又从来没有搞过蓝牙方面的开发,所以就上网找了一下代码。(基本网上有的都是这个)
源码:
WSAQUERYSET querySet;
HANDLE hLookup;
DWORD flags = LUP_RETURN_NAME | LUP_RETURN_ADDR;
union
{
CHAR buf[5000];
double __unused; // ensure proper alignment
};
LPWSAQUERYSET pwsaResults = (LPWSAQUERYSET) buf;
DWORD dwSize = sizeof(buf);
ZeroMemory(pwsaResults, sizeof(WSAQUERYSET));
pwsaResults->dwSize = sizeof(WSAQUERYSET);
pwsaResults->dwNameSpace = NS_BTH;
pwsaResults->lpBlob = NULL;
BOOL bError = FALSE;
BOOL bHaveName;
ZeroMemory(&querySet, sizeof(querySet));
querySet.dwSize = sizeof(querySet);
querySet.dwNameSpace = NS_BTH;
if ( ::WaitForSingleObject ( m_hEvtEndModule, 0 ) == WAIT_OBJECT_0 )
return -1;
if (ERROR_SUCCESS != WSALookupServiceBegin (&querySet, LUP_CONTAINERS, &hLookup))
{
MessageBox ( _T("WSALookupServiceBegin failed") );
return (-1);
}
......
现在的问题是,当运行到WSALookupServiceBegin时,函数总是返回-1,然后就显示WSALookupServiceBegin failed
。请问这个问题如何解决呢???
|
|