UWP GET 我的电脑本地蓝牙 mac 地址

UWP GET my computer local bluetooth mac address

作为主题。我需要获取计算机的本地 mac 地址,但找不到 api.

UWP GET my computer local bluetooth mac address

恐怕您无法使用 UWP api 获取蓝牙无线电 mac 地址,根据您的要求,我们建议您使用 win32 api 获取它,在其他单词在 UWP 桌面扩展中调用 win32 api。 32feet.NET nuget 可以用来获取蓝牙 mac 地址。

代码

public static BluetoothAddress GetBTMacAddress()
{

    BluetoothRadio myRadio = BluetoothRadio.PrimaryRadio;
    if (myRadio == null)
    {
       
        return null;
    }

    return myRadio.LocalAddress;
}

我知道了,从 UWP api 获取的 BluetoothAddress 是十进制数。以上是十六进制数,它们是相同的值。我使用以下内容转换为十六进制。感谢@Mike Petrichenko 在下方的评论。

 var adapter = await BluetoothAdapter.GetDefaultAsync();
 var bleAddress = Convert.ToString(Convert.ToInt64(adapter.BluetoothAddress.ToString()), 16).ToUpper();