2013-11-27 43 views

回答

1

根据MSDN,您可以通过检查拨打PeerFinder.FindAllPeersAsync()时发现的异常HResult来判断蓝牙是否关闭。它们提供以下示例代码:

try 
{ 
    var peers = await PeerFinder.FindAllPeersAsync(); 

    // Handle the result of the FindAllPeersAsync call 
} 
catch (Exception ex) 
{ 
    if ((uint)ex.HResult == 0x8007048F) 
    { 
     MessageBox.Show("Bluetooth is turned off"); 
    } 
} 

要检测设备功能,请查看PeerFinder.SupportedDiscoveryTypes属性。

+0

但如何知道蓝牙是否不存在。 – Kation

+0

查看我对“PeerFinder”属性的编辑,该属性应该能够满足您的需求。 –

+0

我得到了0x80342002 HResult异常...... SurfaceRT只浏览了“PeerFinder.SupportedDiscoveryTypes”。桌面没有它。 – Kation

相关问题