Пример #1
0
        private static BluetoothRadio GetDefault()
        {
            BLUETOOTH_FIND_RADIO_PARAMS p    = BLUETOOTH_FIND_RADIO_PARAMS.Create();
            BLUETOOTH_RADIO_INFO        info = BLUETOOTH_RADIO_INFO.Create();
            IntPtr hRadio = IntPtr.Zero;

            IntPtr findHandle = NativeMethods.BluetoothFindFirstRadio(ref p, out hRadio);

            if (hRadio != IntPtr.Zero)
            {
                int result = NativeMethods.BluetoothGetRadioInfo(hRadio, ref info);
            }

            if (findHandle != IntPtr.Zero)
            {
                NativeMethods.BluetoothFindRadioClose(findHandle);
            }

            if (hRadio != IntPtr.Zero)
            {
                return(new BluetoothRadio(info, hRadio));
            }

            return(null);
        }
Пример #2
0
        private static void GetAllRadios(List <BluetoothRadio> radios)
        {
            BLUETOOTH_FIND_RADIO_PARAMS p    = BLUETOOTH_FIND_RADIO_PARAMS.Create();
            BLUETOOTH_RADIO_INFO        info = BLUETOOTH_RADIO_INFO.Create();
            IntPtr hRadio = IntPtr.Zero;

            IntPtr findHandle = NativeMethods.BluetoothFindFirstRadio(ref p, out hRadio);

            do
            {
                if (hRadio != IntPtr.Zero)
                {
                    int result = NativeMethods.BluetoothGetRadioInfo(hRadio, ref info);
                    radios.Add(new BluetoothRadio(info, hRadio));
                }
            }while (NativeMethods.BluetoothFindNextRadio(findHandle, out hRadio));

            if (findHandle != IntPtr.Zero)
            {
                NativeMethods.BluetoothFindRadioClose(findHandle);
            }
        }