时间:2025-01-04 15:01:01
对wince应用程序的撰写,以用来搜寻到周边的蓝牙设备,必须中用下面3个API函数: (1) INTWSALookupServiceBegin( LPWSAQUERYSETpQuerySet, DWORDdwFlags, LPHANDLElphLookup ); 这个函数主要用途是填满一个回到参数lphLookup,这是一个HANDLE,是给以后的两个函数用的。我们告诉WSA结尾的一般都是winsock函数,这个也不值得注意,只不过是它的第一个参数也就是搜寻集pQuerySet设置成了蓝牙涉及的。WSAQUERYSET结构如下: typedefstruct_WSAQuerySet{ DWORDdwSize; LPTSTRlpszServiceInstanceName; LPGUIDlpServiceClassId; LPWSAVERSIONlpVersion; LPTSTRlpszComment; DWORDdwNameSpace; LPGUIDlpNSProviderId; LPTSTRlpszContext; DWORDdwNumberOfProtocols; LPAFPROTOCOLSlpafpProtocols; LPTSTRlpszQueryString; DWORDdwNumberOfCsAddrs; LPCSADDR_INFOlpcsaBuffer; DWORDdwOutputFlags; LPBLOBlpBlob; }WSAQUERYSET,*PWSAQUERYSETW; 不过对于蓝牙,我们一般这么用: WSAQUERYSETbtQuerySet; memset(btQuerySet;,0,sizeof(btQuerySet;)); btQuerySet.dwSize=sizeof(btQuerySet;); btQuerySet.dwNameSpace=NS_BTH; btQuerySet.lpcsaBuffer=NULL; 再行接着看下第二个参数dwFlags,它的给定如下: LUP_CONTAINERS: Specifiesthatdevicediscoveryistobeperformed.Ifthisflagisnotset,servicediscoverywillbeperformedinstead. LUP_RES_SERVICE: SearchesthelocalSDPdatabase.Clearthisflagtosearchforservicesonapeerdevice. 这里用的是LUP_CONTAINERS IfLUP_CONTAINERSisset,SDPperformsadeviceinquirytofindotherBluetoothdevicesinthearea.Thisfunctionperformsthequery.TheWSALookupServiceNextfunctionretrievestheresultsonedeviceatatime.。
本文来源:澳门bet356体育在线官网安装-www.bdhongluo.com