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);
        }
 private void Register(BluetoothAddress remoteAddress)
 {
     System.Diagnostics.Debug.Assert(m_pin == null ^ m_userCallback == null);
     //
     m_callback = new NativeMethods.BluetoothAuthenticationCallback(NativeCallback);
     BLUETOOTH_DEVICE_INFO bdi = new BLUETOOTH_DEVICE_INFO(remoteAddress);
     UInt32 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);
 }