private void StartBrowser()
        {
            this._WebBrowserExtendedState = Microsoft.Uii.Csr.Browser.Web.WebBrowserExtendedState.BrowserAcquiring;
            this.web = null;
            this.web = (IWebBrowser2)Activator.CreateInstance(Type.GetTypeFromCLSID(NativeMethods.IID_InternetExplorer));
            object flags   = 0;
            object missing = Type.Missing;

            this.web.Navigate("about:blank", ref flags, ref missing, ref missing, ref missing);
            if (web.HWND == 0)
            {
                throw new Exception("Unable to attach to browser.   Protected Mode may be disable");
            }
            this._Process = Process.GetProcessById(NativeMethods.GetProcessIdFromWindow((IntPtr)this.web.HWND));
            if (_Process == null)
            {
                throw new Exception("Unable to attach to browser.   Protected Mode may be disable");
            }
            Win32API.ShowWindow((IntPtr)web.HWND, Win32API.ShowWindowValues.SW_MAXIMIZE);
            this._Process.Exited += _Process_Exited;
            this._Process.EnableRaisingEvents = true;
            this._WebBrowserExtendedState     = Microsoft.Uii.Csr.Browser.Web.WebBrowserExtendedState.BrowserAcquired;
            this.web.AddressBar = AddressBar;
            this.web.MenuBar    = MenuBar;
            this.web.StatusBar  = StatusBar;
            this.web.ToolBar    = ToolBar;
            if (userCanClose == false)
            {
                RemoveBrowserClose((IntPtr)web.HWND);
            }
        }
        public void _CloseBrowser()
        {
            lock (BrowserDestruct)
            {
                if (this._WebBrowserExtendedState != WebBrowserExtendedState.BrowserAcquired)
                {
                    return;
                }
                if (this.web != null)
                {
                    UnsinkEvents();

                    if (this._Process != null)
                    {
                        this._Process.Exited -= processExitedHandler;
                    }

                    try
                    {
                        this.web.Quit();
                        if (this.web is IDisposable)
                        {
                            ((IDisposable)web).Dispose();
                        }
                    }
                    catch (COMException exception)
                    {
                        Trace.WriteLine(string.Format("COM Exception happened while closing IE {0} ", exception.Message));
                    }
                    finally
                    {
                        this.web = null;
                    }
                }
                this._WebBrowserExtendedState = Microsoft.Uii.Csr.Browser.Web.WebBrowserExtendedState.BrowserNotAcquired;
            }
        }
        private void StartBrowser(string url)
        {
            this._WebBrowserExtendedState = Microsoft.Uii.Csr.Browser.Web.WebBrowserExtendedState.BrowserAcquiring;
            ChromeLauncher cl = new ChromeLauncher();

            _Process = cl.OpenLink(url);
            if (_Process == null)
            {
                throw new Exception("Unable to attach to browser.   Protected Mode may be disable");
            }
            _webBrowser           = cl.ChromeWindow;
            this._Process.Exited += _Process_Exited;
            this._Process.EnableRaisingEvents = true;
            this._WebBrowserExtendedState     = Microsoft.Uii.Csr.Browser.Web.WebBrowserExtendedState.BrowserAcquired;
            if (_webBrowser != IntPtr.Zero)
            {
                ManipulateWindow();
            }
            else
            {
                browserAquiredStart = DateTime.Now;
                browserAquiredTimer = new System.Threading.Timer(new TimerCallback(BrowserAquiredCheck), null, TimeSpan.FromMilliseconds(300), TimeSpan.Zero);
            }
        }
 public void _CloseBrowser()
 {
     this._WebBrowserExtendedState = Microsoft.Uii.Csr.Browser.Web.WebBrowserExtendedState.BrowserNotAcquired;
     Dispose();
 }