谢欣伦 - OpenDev原创教程 - 蓝牙设备查找类CxBthRadio & CxBthRadioFind

  这是一个精练的蓝牙设备查找类,类名、函数名和变量名均采用匈牙利命名法。小写的x代表我的姓氏首字母(谢欣伦),个人习惯而已,如有雷同,纯属巧合。

CxBthRadioFind的使用如下:

void CUsbScannerDlg::OnBtnLocalBth() 
{
    // TODO: Add your control notification handler code here
    m_list1.ResetContent();
    
    BTH_DEV_INFO bdi = {0};
    CString str;
    CxBthRadioFind finder;
    BOOL bRet = finder.FindRadio();
    while (bRet)
    {
        finder.GetDeviceInfo(&bdi);
        m_list1.AddString(bdi.szName);
        m_list1.AddString(bdi.szMacAddr);
        
        str.Format(_T("Class of Device : 0x%08x"), bdi.ulClassofDevice);
        m_list1.AddString(str);

        m_list1.AddString("");
        m_list1.AddString("-->Next<--");
        bRet = finder.FindNextRadio();
    }
    finder.FindRadioClose();
}

CxBthRadio的使用如下:

void CUsbScannerDlg::OnBtnCurRemoteBthDev() 
{
    // TODO: Add your control notification handler code here
    m_list1.ResetContent();

    BTH_DEV_INFO bdi = {0};
    BOOL bRetLocalFind, bRetRemoteFind;
    CString str;
    CxBthRadioFind local_bth_find;
    CxBthRadio local_bth;

    bRetLocalFind = local_bth_find.FindRadio(FALSE);
    while (bRetLocalFind)
    {
        local_bth.Attach(local_bth_find.GetRadioHandle());

        bRetRemoteFind = local_bth.FindRemoteDevice(FALSE);
        while (bRetRemoteFind)
        {
            local_bth.GetRemoteDeviceInfo(&bdi);
            m_list1.AddString(bdi.szName);
            m_list1.AddString(bdi.szMacAddr);
            
            str.Format(_T("Class of Device : 0x%08x"), bdi.ulClassofDevice);
            m_list1.AddString(str);
            
            m_list1.AddString("");
            m_list1.AddString("-->Next<--");
            bRetRemoteFind = local_bth.FindNextRemoteDevice();
        }
        local_bth.FindRemoteDeviceClose();

        local_bth_find.CloseRadioHandle();

        bRetLocalFind = local_bth_find.FindNextRadio(FALSE);
    }
    local_bth_find.FindRadioClose();
}

  精练的代码不需要过多解释,你们懂的。To be continued...

下载

libComm - v1.2 For WinXP/Win7

转载于:https://www.cnblogs.com/EdmundDwyane/p/3292454.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值