public Win32BluetoothWin32Authentication(BluetoothAddress address, string pin)
        {
            Address = address;
            _pin    = pin;
            BLUETOOTH_DEVICE_INFO device = BLUETOOTH_DEVICE_INFO.Create();

            device.Address = address;
            NativeMethods.BluetoothGetDeviceInfo(IntPtr.Zero, ref device);
            _callback = new NativeMethods.BluetoothAuthenticationCallbackEx(Callback);

            NativeMethods.BluetoothRegisterForAuthenticationEx(ref device, out _handle, _callback, IntPtr.Zero);
        }
        private void Register(BluetoothAddress remoteAddress)
        {
            System.Diagnostics.Debug.Assert(m_pin == null ^ m_userCallback == null);
            //
            m_callback   = new NativeMethods.BluetoothAuthenticationCallback(NativeCallback);
            m_callbackEx = new NativeMethods.BluetoothAuthenticationCallbackEx(NativeCallback);
            BLUETOOTH_DEVICE_INFO bdi = new BLUETOOTH_DEVICE_INFO(remoteAddress);
            UInt32 ret;

            if (m_hasKB942567)
            {
                try {
                    ret = NativeMethods.BluetoothRegisterForAuthenticationEx(
                        ref bdi, out m_regHandle, m_callbackEx, IntPtr.Zero);
                } catch (EntryPointNotFoundException) {
                    m_hasKB942567 = false;
                    ret           = NativeMethods.BluetoothRegisterForAuthentication(
                        ref bdi, out m_regHandle, m_callback, IntPtr.Zero);
                }
            }
            else
            {
                ret = NativeMethods.BluetoothRegisterForAuthentication(
                    ref bdi, out m_regHandle, m_callback, IntPtr.Zero);
            }
            int gle = Marshal.GetLastWin32Error();

            System.Diagnostics.Debug.Assert(ret == NativeErrorSuccess,
                                            "BluetoothRegisterForAuthentication failed, GLE="
                                            + gle.ToString() + "=0x" + gle.ToString("X"));
            if (ret != NativeErrorSuccess)
            {
                throw new System.ComponentModel.Win32Exception(gle);
            }
            m_regHandle.SetObjectToKeepAlive(m_callback, m_callbackEx);
        }