⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bluetoothsecurity.cs

📁 蓝牙传输控件,用于蓝牙文件上传和下载。芯片只要选用crs
💻 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 + -