/// <summary>
        /// Creates an instance of the <see cref="T:WebBrowser"/>.
        /// </summary>
        /// <param name="activeXWebBrowser">The ActiveX Web Browser.</param>
        /// <returns>An instance of <see cref="T:WebBrowser"/> or <see langword="null"/> if <paramref name="activeXWebBrowser"/> is <see langword="null"/>.</returns>
        internal static WebBrowser Create(Interop.UnsafeNativeMethods.IWebBrowser2 activeXWebBrowser)
        {
            if (activeXWebBrowser == null)
            {
                return(null);
            }

            return(new WebBrowser(activeXWebBrowser));
        }
 /// <summary>
 /// Determines whether two <see cref="T:Interop.UnsafeNativeMethods.IWebBrowser2"/> are the same.
 /// </summary>
 /// <param name="activeXWebBrowser1">The first <see cref="T:Interop.UnsafeNativeMethods.IWebBrowser2"/> to compare.</param>
 /// <param name="activeXWebBrowser2">The second <see cref="T:Interop.UnsafeNativeMethods.IWebBrowser2"/> to compare.</param>
 /// <returns>
 /// <see langword="true" /> if the two <see cref="T:Interop.UnsafeNativeMethods.IWebBrowser2"/> are the same; otherwise, <see langword="false" />.
 /// </returns>
 private static bool ActiveXWebBrowserEquals(Interop.UnsafeNativeMethods.IWebBrowser2 activeXWebBrowser1, Interop.UnsafeNativeMethods.IWebBrowser2 activeXWebBrowser2)
 {
     try
     {
         return(GetPtrForActiveXWebBrowser(activeXWebBrowser1) == GetPtrForActiveXWebBrowser(activeXWebBrowser2));
     }
     catch (Exception ex)
     {
         System.Diagnostics.Trace.WriteLine(ex);
         return(false);
     }
 }
        /// <summary>
        /// Gets the <see cref="T:IntPtr"/> for <see cref="T:Interop.UnsafeNativeMethods.IWebBrowser2"/>.
        /// </summary>
        /// <param name="activeXWebBrowser">The <see cref="T:Interop.UnsafeNativeMethods.IWebBrowser2"/>.</param>
        /// <returns>The <see cref="T:IntPtr"/> for <see cref="T:Interop.UnsafeNativeMethods.IWebBrowser2"/>.</returns>
        private static IntPtr GetPtrForActiveXWebBrowser(Interop.UnsafeNativeMethods.IWebBrowser2 activeXWebBrowser)
        {
            IntPtr activeXWebBrowserPtr = IntPtr.Zero;

            try
            {
                activeXWebBrowserPtr = System.Runtime.InteropServices.Marshal.GetComInterfaceForObject(activeXWebBrowser, typeof(Interop.UnsafeNativeMethods.IWebBrowser2));
            }
            finally
            {
                if (activeXWebBrowserPtr != IntPtr.Zero)
                {
                    System.Runtime.InteropServices.Marshal.Release(activeXWebBrowserPtr);
                }
            }

            return(activeXWebBrowserPtr);
        }