Exemplo n.º 1
0
        public static BluetoothAdapter GetDefault()
        {
            if (s_default == null)
            {
                NativeMethods.BLUETOOTH_FIND_RADIO_PARAMS p = new NativeMethods.BLUETOOTH_FIND_RADIO_PARAMS();
                p.dwSize = Marshal.SizeOf(p);
                IntPtr radioHandle;
                IntPtr findHandle = NativeMethods.BluetoothFindFirstRadio(ref p, out radioHandle);
                if (findHandle != IntPtr.Zero)
                {
                    NativeMethods.BLUETOOTH_RADIO_INFO radioInfo = new NativeMethods.BLUETOOTH_RADIO_INFO();
                    radioInfo.dwSize = Marshal.SizeOf(radioInfo);
                    if (NativeMethods.BluetoothGetRadioInfo(radioHandle, ref radioInfo) == 0)
                    {
                        s_default = new BluetoothAdapter(radioHandle, radioInfo);
                    }

                    NativeMethods.BluetoothFindRadioClose(findHandle);
                }
            }

            return(s_default);
        }
Exemplo n.º 2
0
 internal BluetoothDeviceReceiver(BluetoothAdapter parent)
 {
     _parent = parent;
 }