📄 bluetoothsecurity.cs
字号:
using System;
using System.Runtime.InteropServices;
using Microsoft.Win32;
namespace bluetoothX
{
public static class BluetoothSecurity
{
public static bool PairRequest(BluetoothAddress device, string pin)
{
BLUETOOTH_DEVICE_INFO bdi = new BLUETOOTH_DEVICE_INFO(device.ToInt64());
int result = NativeMethods.BluetoothGetDeviceInfo(IntPtr.Zero, ref bdi);
result = NativeMethods.BluetoothAuthenticateDevice(IntPtr.Zero, IntPtr.Zero, ref bdi, pin, pin.Length);
if (0 != result && 259 != result)
{
return false;
}
return true;
}
public static bool RemoveDevice(BluetoothAddress device)
{
int result = NativeMethods.BluetoothRemoveDevice(device.ToByteArray());
if (0 == result)
{
return true;
}
return false;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -