To unapir classic Bluetooth device you have to call BluetoothRemoveDevice function.
For .NET it can be imported as below
[StructLayout(LayoutKind.Explicit)]
struct BLUETOOTH_ADDRESS
{
[FieldOffset(0)]
[MarshalAs(UnmanagedType.I8)]
public Int64 ullLong;
[FieldOffset(0)]
[MarshalAs(UnmanagedType.U1)]
public Byte rgBytes_0;
[FieldOffset(1)]
[MarshalAs(UnmanagedType.U1)]
public Byte rgBytes_1;
[FieldOffset(2)]
[MarshalAs(UnmanagedType.U1)]
public Byte rgBytes_2;
[FieldOffset(3)]
[MarshalAs(UnmanagedType.U1)]
public Byte rgBytes_3;
[FieldOffset(4)]
[MarshalAs(UnmanagedType.U1)]
public Byte rgBytes_4;
[FieldOffset(5)]
[MarshalAs(UnmanagedType.U1)]
public Byte rgBytes_5;
};
[DllImport("BluetoothAPIs.dll", SetLastError = true, CallingConvention = CallingConvention.StdCall)]
[return: MarshalAs(UnmanagedType.U4)]
static extern UInt32 BluetoothRemoveDevice(
[param: In, Out] ref BLUETOOTH_ADDRESS pAddress);
Here is how to call it:
UInt32 Unpair(Int64 Address)
{
BLUETOOTH_ADDRESS Addr = new BLUETOOTH_ADDRESS();
Addr.ullLong = Address;
return BluetoothRemoveDevice(ref Addr);
}
Please not that this function allows to unpair Classic Bluetooth devices only. To unpair Bluetooth LE devices you have to use other way based on WinRT.