Exemplo n.º 1
0
        /// <summary>
        /// Used to attach the appropriate interface to Windows Media Player.
        /// In here, we call SetClientSite on the WMP Control, passing it
        /// the dotNet container (this instance.)
        /// </summary>
        protected override void AttachInterfaces()
        {
            try
            {
                //Get the IOleObject for Windows Media Player.
                IOleObject oleObject = this.GetOcx() as IOleObject;

                if (oleObject != null)
                {
                    //Set the Client Site for the WMP control.
                    oleObject.SetClientSite(this as IOleClientSite);

                    // Try and get the OCX as a WMP player
                    if (this.GetOcx() as IWMPPlayer4 == null)
                    {
                        throw new Exception(string.Format("OCX is not an IWMPPlayer4! GetType returns '{0}'",
                                                          this.GetOcx().GetType()));
                    }
                }
                else
                {
                    throw new Exception("Failed to get WMP OCX as an IOleObject?!");
                }

                return;
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }
        }
Exemplo n.º 2
0
        private object CreateNewWebPage(string url)
        {
            TabPage tabPage = new TabPage("新标签页");

            tabPage.Name = "tabPage" + (tabControl1.TabPages.Count + 1);

            WebPage webPage = new WebPage();

            webPage.Dock              = DockStyle.Fill;
            webPage.Tag               = tabPage;
            webPage.NewPage          += WebPage_NewPage;
            webPage.StatusTextChange += WebPage_StatusTextChange;
            webPage.TitleChange      += WebPage_TitleChange;
            IOleObject obj = (IOleObject)webPage.GetActiveXInstance();

            obj.SetClientSite(this);

            tabPage.Controls.Add(webPage);
            tabControl1.TabPages.Add(tabPage);
            tabControl1.SelectedTab = tabPage;

            if (url != null && url.Length > 0)
            {
                webPage.Navigate(url);
            }
            else
            {
                webPage.FocusAddressInput();
            }

            return(webPage.GetActiveXInstance());
        }
Exemplo n.º 3
0
        public static void LoadUrl(ref HTMLDocument doc, String url, bool CreateSite)
        {
            if (doc == null)
            {
                throw new HtmlEditorException("Null document passed to LoadDocument");
            }

            if (CreateSite)
            {
                //set client site to DownloadOnlySite, to suppress scripts
                DownloadOnlySite ds = new DownloadOnlySite();
                IOleObject       ob = (IOleObject)doc;
                ob.SetClientSite(ds);
            }

            IPersistMoniker persistMoniker = (IPersistMoniker)doc;

            IMoniker moniker = null;

            int iResult = win32.CreateURLMoniker(null, url, out moniker);

            IBindCtx bindContext = null;

            iResult = win32.CreateBindCtx(0, out bindContext);

            iResult = persistMoniker.Load(0, moniker, bindContext, constants.STGM_READ);

            persistMoniker = null;

            bindContext = null;

            moniker = null;
        }
Exemplo n.º 4
0
        public RemotedWindowsMediaPlayer()
        {
            // Create the Windows Media Player object
            Type   type     = Type.GetTypeFromCLSID(new Guid("6bf52a52-394a-11d3-b153-00c04f79faa6"));
            object instance = Activator.CreateInstance(type);

            //Get the IOleObject for Windows Media Player.
            IOleObject oleObject = instance as IOleObject;

            if (oleObject == null)
            {
                throw new Exception("Failed to get WMP OCX as an IOleObject?!");
            }

            //Set the Client Site for the WMP control.
            oleObject.SetClientSite(this as IOleClientSite);

            // Try and get the OCX as a WMP player
            m_instance = instance as IWMPPlayer4;
            if (m_instance == null)
            {
                Marshal.FinalReleaseComObject(instance);
                throw new Exception(string.Format("OCX is not an IWMPPlayer4! GetType returns '{0}'", m_instance.GetType()));
            }
        }
Exemplo n.º 5
0
        public void CreateDocument()
        {
            Debug.Assert(m_document == null, "Must call Close before recreating.");

            Boolean created = false;

            try
            {
                m_document = (IOleObject) new mshtml.HTMLDocument();

                int iRetval = ComSupport.OleRun(m_document);


                m_document.SetClientSite(this);

                // Lock the object in memory
                iRetval = ComSupport.OleLockRunning(m_document, true, false);

                m_document.SetHostNames("HtmlEditor", "HtmlEditor");
                m_document.Advise(this, out iAdviseCookie);

                created = true;
            }
            finally
            {
                if (created == false)
                {
                    m_document = null;
                }
            }
        }
Exemplo n.º 6
0
        public void SetProxy()
        {
            if (ImageResolver.Instance.UseProxy)
            {
                var proxy = ImageResolver.Instance.GetCorrectCurrentWebProxy;
                if (proxy == null)
                {
                    SetProxyServer(null);
                }
                else
                {
                    object     obj = webBrowser.ActiveXInstance;
                    IOleObject oc  = obj as IOleObject;
                    oc.SetClientSite(this as IOleClientSite);

                    _currentUsername = ImageResolver.Instance.ProxyUsers[proxy].UserName;
                    _currentPassword = ImageResolver.Instance.ProxyUsers[proxy].Password;
                    SetProxyServer(proxy.Address.ToString());

                    webBrowser.Navigate("about:blank");
                    Application.DoEvents();
                }
            }
            else
            {
                SetProxyServer(null);
            }
        }
Exemplo n.º 7
0
        protected override void AttachInterfaces()
        {
            IOleObject oleObject = (IOleObject)this.GetOcx();

            if (oleObject != null)
            {
                oleObject.SetClientSite((IOleClientSite)this);
            }
        }
Exemplo n.º 8
0
        private void Init()
        {
            //Get the IOleObject for Windows Media Player.
            IOleObject oleObject = this.GetOcx() as IOleObject;

            //Set the Client Site for the WMP control.
            oleObject.SetClientSite(this as IOleClientSite);

            Player = this.GetOcx() as WindowsMediaPlayer;
        }
Exemplo n.º 9
0
        /// <summary>
        /// Initializes OLE objects necessary for
        /// bypassing prompt dialogs
        /// </summary>
        public void InitializeOLE()
        {
            this.Navigate("about:blank");
            while (this.ReadyState != WebBrowserReadyState.Complete)
            {
                Application.DoEvents();
            }
            object     obj = this.ActiveXInstance;
            IOleObject oc  = obj as IOleObject;

            oc.SetClientSite(this as IOleClientSite);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Add OLE objects necessary for bypassing prompt dialogs
        /// </summary>
        public void InitialiseOLE()
        {
            object     obj = this.ActiveXInstance;
            IOleObject oc  = obj as IOleObject;

            oc.SetClientSite(this as IOleClientSite);
            // Add Support for bypassing Proxy Authentication dialog
            AuthenticateProxy += delegate(object sender, EnhancedBrowser.AthenticateProxyEventArgs e)
            {
                e.Username = Proxy.Username;
                e.Password = Proxy.Password;
            };
        }
Exemplo n.º 11
0
        public void HookUp(IOleObject obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }

            int rc = obj.SetClientSite(this);

            if (rc != 0)
            {
                throw new COMException(ErrorMessages.UnknownComError, rc);
            }
        }
Exemplo n.º 12
0
        public void HookUp(WebBrowserBase webBrowser)
        {
            if (webBrowser == null)
            {
                throw new ArgumentNullException("webBrowser");
            }

            IOleObject oleObject = (IOleObject)webBrowser.ActiveXInstance;
            int        rc        = oleObject.SetClientSite(this);

            if (rc != 0)
            {
                throw new COMException(ErrorMessages.UnknownComError, rc);
            }
        }
Exemplo n.º 13
0
        public ExplorerBrowserControlClientSite(object browser)
        {
            // Set us as the client site
            //
            // It seems a bit dodgy to set ourselves as the client site since we don't
            // implement all the interfaces that may be exposed by the provided client site.  It
            // appears, however, that none of those interfaces are called once the browserControl
            // has been loaded, so this appears safe.  See the description in the links below for
            // additional discussion.
            //
            // http://www.codeproject.com/books/0764549146_8.asp
            // http://discuss.develop.com/archives/wa.exe?A2=ind0205A&L=DOTNET&D=0&P=15756
            IOleObject oleObject = (IOleObject)browser;

            oleObject.SetClientSite(this);
        }
Exemplo n.º 14
0
 public void Navicate(string Url)
 {
     try
     {
         if (webBrowser != null)
         {
             this.webBrowser.Navigate(Url);
             object obj = webBrowser.ActiveXInstance;
             oc = obj as IOleObject;
             oc.SetClientSite(this as IOleClientSite);
         }
     }
     catch (Exception ex)
     {
         LogManage.WriteLog(this.GetType(), ex);
     }
 }
        public void DoInterfaceAttachment()
        {
            try
            {
                //Get the IOleObject for Windows Media Player.
                _oleObject = this.GetOcx() as IOleObject;

                //Set the Client Site for the WMP control.
                _oleObject.SetClientSite(this as IOleClientSite);

                this.ocx = ((WMPLib.IWMPPlayer4)(this.GetOcx()));
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Initialize the downloader
        /// </summary>
        public WebPageDownloader()
        {
            // create the underlying control
            browserControl = new ExplorerBrowserControl();

            // set us as the client site
            // http://www.codeproject.com/books/0764549146_8.asp
            // http://discuss.develop.com/archives/wa.exe?A2=ind0205A&L=DOTNET&D=0&P=15756
            IOleObject oleObject = (IOleObject)browserControl.Browser;

            oleObject.SetClientSite(this);

            // configure options
            browserControl.Browser.Silent = true;

            // subscribe to events
            browserControl.ProgressChange   += new BrowserProgressChangeEventHandler(browserControl_ProgressChange);
            browserControl.DocumentComplete += new BrowserDocumentEventHandler(browserControl_DocumentComplete);
            browserControl.NewWindow2       += new Project31.BrowserControl.DWebBrowserEvents2_NewWindow2EventHandler(browserControl_NewWindow2);
        }
Exemplo n.º 17
0
        public void CreateDocument()
        {
            Debug.Assert(m_document == null, "Must call Close before recreating.");

            Boolean created = false;

            try
            {
                m_document = (IOleObject) new HTMLDocument();

                int iRetval;

                iRetval = win32.OleRun(m_document);

                iRetval = m_document.SetClientSite(this);

                Debug.Assert(iRetval == HRESULT.S_OK, "SetClientSite failed");

                // Lock the object in memory
                iRetval = win32.OleLockRunning(m_document, true, false);

                m_document.SetHostNames("HtmlEditor", "HtmlEditor");
                m_document.Advise(this, out iAdviseCookie);

                //hook up HTMLDocumentEvents2
                Guid guid = new Guid("3050f613-98b5-11cf-bb82-00aa00bdce0b");
                IConnectionPointContainer icpc = (IConnectionPointContainer)m_document;

                icpc.FindConnectionPoint(ref guid, out icp);
                icp.Advise(this, out iEventsCookie);

                created = true;
            }
            finally
            {
                if (created == false)
                {
                    m_document = null;
                }
            }
        }
Exemplo n.º 18
0
 public void StopParsing()
 {
     try
     {
         //UnAdvice and clean up
         if ((m_WBConnectionPoint != null) && (m_dwCookie > 0))
         {
             m_WBConnectionPoint.Unadvise(m_dwCookie);
         }
         if (m_WBOleObject != null)
         {
             m_WBOleObject.Close((uint)OLEDOVERB.OLECLOSE_NOSAVE);
             m_WBOleObject.SetClientSite(null);
         }
         if (m_pMSHTML != null)
         {
             Marshal.ReleaseComObject(m_pMSHTML);
             m_pMSHTML = null;
         }
         if (m_WBConnectionPoint != null)
         {
             Marshal.ReleaseComObject(m_WBConnectionPoint);
             m_WBConnectionPoint = null;
         }
         if (m_WBOleControl != null)
         {
             Marshal.ReleaseComObject(m_WBOleControl);
             m_WBOleControl = null;
         }
         if (m_WBOleObject != null)
         {
             Marshal.ReleaseComObject(m_WBOleObject);
             m_WBOleObject = null;
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        cHTMLParser()
        {
            //Create a new MSHTML, throws exception if fails
            Type htmldoctype = Type.GetTypeFromCLSID(Iid_Clsids.CLSID_HTMLDocument, true);
            //Using Activator inplace of CoCreateInstance, returns IUnknown
            //which we cast to a IHtmlDocument2 interface
            m_pMSHTML = (IHTMLDocument2)System.Activator.CreateInstance(htmldoctype);

            //Get the IOleObject
            m_WBOleObject = (IOleObject)m_pMSHTML;
            //Set client site
            int iret = m_WBOleObject.SetClientSite(this);

            //Connect for IPropertyNotifySink
            m_WBOleControl = (IOleControl)m_pMSHTML;
            m_WBOleControl.OnAmbientPropertyChange(HTMLDispIDs.DISPID_AMBIENT_DLCONTROL);

            //Get connectionpointcontainer
            IConnectionPointContainer cpCont = (IConnectionPointContainer)m_pMSHTML;
            cpCont.FindConnectionPoint(ref Iid_Clsids.IID_IPropertyNotifySink, out m_WBConnectionPoint);
            //Advice
            m_WBConnectionPoint.Advise(this, out m_dwCookie);
        }
        public void DoInterfaceAttachment()
        {
            if (!_isControlLoaded)
            {
                try
                {
                    //Get the IOleObject for Windows Media Player.
                    _oleObject       = this.GetOcx() as IOleObject;
                    _isControlLoaded = true;
                }
                catch (System.Exception ex)
                {
                    //System.Diagnostics.Debug.WriteLine(ex.ToString());
                }
            }

            if (!_isControlSited)
            {
                try
                {
                    //Set the Client Site for the WMP control.
                    _oleObject.SetClientSite(this as IOleClientSite);
                    _isControlSited = true;
                }
                catch (Exception ex)
                {
                    // This doesn't appear to have any effect on things, so once fired
                    // don't attempt to fire it again
                    _isControlSited = true;
                }
            }

            if (_controlOcx == null)
            {
                _controlOcx = ((WMPLib.IWMPPlayer4)(this.GetOcx()));
            }
        }
Exemplo n.º 21
0
        public void HookUp( IOleObject obj )
        {
            if ( obj == null )
            {
                throw new ArgumentNullException( "obj" );
            }

            int rc = obj.SetClientSite( this );
            if ( rc != 0 )
            {
                throw new COMException( ErrorMessages.UnknownComError, rc );
            }
        }
Exemplo n.º 22
0
        public void CloseDocument()
        {
            try
            {
                container.releaseWndProc();
                container.Resize -= new EventHandler(this.Container_Resize);

                if (m_document == null)
                {
                    return;
                }

                try
                {
                    //this may raise an exception, however it does work and must
                    //be called
                    if (view != null)
                    {
                        view.Show(-1);
                        view.UIActivate(-1);
                        view.SetInPlaceSite(null);
                        view.CloseView(0);
                    }
                }
                catch (Exception e)
                {
                    Debug.WriteLine("CloseView raised exception: " + e.Message);
                }

                try
                {
                    //this could raise an exception too, but it must be called
                    m_document.Close((int)tagOLECLOSE.OLECLOSE_NOSAVE);
                }
                catch (Exception e)
                {
                    Debug.WriteLine("Close document raised exception: " + e.Message);
                }

                m_document.SetClientSite(null);

                win32.OleLockRunning(m_document, false, false);

                if (this.iAdviseCookie != 0)
                {
                    m_document.Unadvise(this.iAdviseCookie);
                }

                if (this.iEventsCookie != 0)
                {
                    m_document.Unadvise(this.iEventsCookie);
                }

                if (this.iPropertyNotifyCookie != 0)
                {
                    m_document.Unadvise(this.iPropertyNotifyCookie);
                }

                if (container.changeCookie != 0)
                {
                    ((IMarkupContainer2)m_document).UnRegisterForDirtyRange(container.changeCookie);
                    container.changeCookie = 0;
                }

                //release COM objects
                int RefCount = 0;

                if (m_document != null)
                {
                    do
                    {
                        RefCount = Marshal.ReleaseComObject(m_document);
                    } while (RefCount > 0);
                }

                if (view != null)
                {
                    do
                    {
                        RefCount = Marshal.ReleaseComObject(view);
                    } while (RefCount > 0);
                }

                if (activeObject != null)
                {
                    do
                    {
                        RefCount = Marshal.ReleaseComObject(activeObject);
                    } while (RefCount > 0);
                }

                m_document         = null;
                view               = null;
                activeObject       = null;
                container.mHtmlDoc = null;
                container.mDocHTML = null;
            }
            catch (Exception e)
            {
                Debug.WriteLine("CloseDocument raised exception: " + e.Message);
            }
        }
Exemplo n.º 23
0
        public void CreateDocument()
        {
            Debug.Assert(m_document == null, "Must call Close before recreating.");

            Boolean created = false;
            try
            {
                m_document = (IOleObject)new HTMLDocument();

                int iRetval;

                iRetval = win32.OleRun(m_document);

                iRetval = m_document.SetClientSite(this);

                Debug.Assert(iRetval == HRESULT.S_OK, "SetClientSite failed");

                // Lock the object in memory
                iRetval = win32.OleLockRunning(m_document, true, false);

                m_document.SetHostNames("HtmlEditor", "HtmlEditor");
                m_document.Advise(this, out iAdviseCookie);

                //hook up HTMLDocumentEvents2
                Guid guid = new Guid("3050f613-98b5-11cf-bb82-00aa00bdce0b");
                IConnectionPointContainer icpc = (IConnectionPointContainer)m_document;

                icpc.FindConnectionPoint(ref guid, out icp);
                icp.Advise(this, out iEventsCookie);

                created = true;
            }
            finally
            {
                if (created == false)
                    m_document = null;
            }
        }
Exemplo n.º 24
0
        public HtmlRenderer(IArachnodeDAO arachnodeDAO)
        {
            Type htmldoctype = Type.GetTypeFromCLSID(Iid_Clsids.CLSID_HTMLDocument, true);

            //Using Activator inplace of CoCreateInstance, returns IUnknown
            //which we cast to a IHtmlDocument2 interface
            MSHTML = (IHTMLDocument4)Activator.CreateInstance(htmldoctype);

            IPersistStreamInit ips = (IPersistStreamInit)MSHTML;

            ips.InitNew();

            IOleObject oleObject = (IOleObject)MSHTML;
            //Set client site
            int iret = oleObject.SetClientSite(this);

            CrawlRequestTimeoutInMinutes = 1;

            //Getting exceptions when trying to get change notification through IPropertyNotifySink and connectionpointcontainer.
            //So, using this technique.
            Thread t = new Thread(() =>
            {
                string previousReadyState = "";
                while (true)
                {
                    try
                    {
                        if (_parse.WaitOne())
                        {
                            if (DateTime.Now.Subtract(_parseStartTime).TotalMinutes < CrawlRequestTimeoutInMinutes)
                            {
                                string currentReadyState = ((IHTMLDocument2)MSHTML).readyState;

                                if (string.Compare(currentReadyState, previousReadyState, true) != 0)
                                {
                                    previousReadyState = currentReadyState;

                                    ReadyState = ReadyState.Uninitialized;
                                    switch (currentReadyState.ToLower())
                                    {
                                    case "loading":
                                        ReadyState = ReadyState.Loading;
                                        break;

                                    case "loaded":
                                        ReadyState = ReadyState.Loaded;
                                        break;

                                    case "interactive":
                                        ReadyState = ReadyState.Interactive;
                                        ModifyDOM(((IHTMLDocument2)MSHTML), true);
                                        break;

                                    case "complete":
                                        ReadyState = ReadyState.Complete;
                                        break;

                                    default:
                                        ReadyState = ReadyState.Uninitialized;
                                        break;
                                    }

                                    if (ReadyStateChange != null)
                                    {
                                        ReadyStateChange(this, new ReadyStateChangeEventArgs(ReadyState, ((IHTMLDocument2)MSHTML)));
                                    }
                                }

                                if (ReadyState == ReadyState.Complete)
                                {
                                    EndRendering();

                                    previousReadyState = "";
                                }
                            }
                            else
                            {
                                throw new Exception("The AbsoluteUri timed out while rendering.");
                            }

                            Thread.Sleep(100);
                        }
                    }
                    catch (Exception exception)
                    {
                        EndRendering();

                        previousReadyState = "";

                        arachnodeDAO.InsertException(AbsoluteUri, AbsoluteUri, exception, false);
                    }
                }
            });

            t.SetApartmentState(ApartmentState.STA);
            t.Start();
        }
Exemplo n.º 25
0
        public static void LoadDocument(ref HTMLDocument doc, String documentVal, bool LoadAsAnsi, bool CreateSite, Encoding EncodingToAddPreamble)
        {
            if (doc == null)
            {
                throw new HtmlEditorException("Null document passed to LoadDocument");
            }

            IHTMLDocument2 htmldoc = (IHTMLDocument2)doc;

            bool isWin98 = (System.Environment.OSVersion.Platform == PlatformID.Win32Windows);

            if (documentVal == string.Empty)
            {
                documentVal = "<html></html>";
            }

            if (CreateSite)
            {
                //set client site to DownloadOnlySite, to suppress scripts
                DownloadOnlySite ds = new DownloadOnlySite();
                IOleObject       ob = (IOleObject)doc;
                ob.SetClientSite(ds);
            }

            IStream stream = null;

            if (isWin98 | LoadAsAnsi)
            {
                win32.CreateStreamOnHGlobal(Marshal.StringToHGlobalAnsi(documentVal), 1, out
                                            stream);
            }
            else
            {
                if (!isBOMPresent(documentVal))
                //add bytemark if needed
                {
                    if (EncodingToAddPreamble != null)
                    {
                        byte[] preamble      = EncodingToAddPreamble.GetPreamble();
                        String byteOrderMark = EncodingToAddPreamble.GetString(preamble, 0, preamble.Length);
                        documentVal = byteOrderMark + documentVal;
                    }
                }

                win32.CreateStreamOnHGlobal(Marshal.StringToHGlobalUni(documentVal), 1, out stream);
            }

            if (stream == null)
            {
                throw new HtmlEditorException("Could not allocate document stream");
            }


            if (isWin98)
            {
                //fix string termination on Win98
                ulong  thesize = 0;
                IntPtr ptr     = IntPtr.Zero;

                int iSizeOfInt64 = Marshal.SizeOf(typeof(Int64));
                ptr = Marshal.AllocHGlobal(iSizeOfInt64);

                if (ptr == IntPtr.Zero)
                {
                    throw new HtmlEditorException("Could not load document");
                }

                //seek to end of stream
                stream.Seek(0, 2, ptr);
                //read the size
                thesize = (ulong)Marshal.ReadInt64(ptr);
                //free the pointer
                Marshal.FreeHGlobal(ptr);

                //truncate the stream
                stream.SetSize((long)thesize);

                //2nd param, 0 is beginning, 1 is current, 2 is end

                if (thesize != (ulong)documentVal.Length + 1)
                {
                    //fix the size by truncating the stream
                    Debug.Assert(true, "Size of stream is unexpected", "The size of the stream is not equal to the length of the string passed to it.");
                    stream.SetSize(documentVal.Length + 1);
                }
            }

            //set stream to start

            stream.Seek(0, 0, IntPtr.Zero);
            //2nd param, 0 is beginning, 1 is current, 2 is end

            IPersistStreamInit persistentStreamInit = (IPersistStreamInit)
                                                      doc;

            if (persistentStreamInit != null)
            {
                int iRetVal = 0;
                iRetVal = persistentStreamInit.InitNew();
                if (iRetVal == HRESULT.S_OK)
                {
                    iRetVal = persistentStreamInit.Load(stream);

                    if (iRetVal != HRESULT.S_OK)
                    {
                        throw new HtmlEditorException("Could not load document");
                    }
                }
                else
                {
                    throw new HtmlEditorException("Could not load document");
                }
                persistentStreamInit = null;
            }
            else
            {
                throw new HtmlEditorException("Could not load document");
            }

            stream = null;
        }
Exemplo n.º 26
0
        public Renderer()
        {
            try
            {
                InitializeComponent();

                /**/

                //remove limits from service point manager
                ServicePointManager.MaxServicePoints = 10000;
                ServicePointManager.DefaultConnectionLimit = 10000;
                ServicePointManager.CheckCertificateRevocationList = true;
                ServicePointManager.Expect100Continue = false;
                ServicePointManager.MaxServicePointIdleTime = 1000 * 30;
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
                ServicePointManager.UseNagleAlgorithm = false;

                //Use if you encounter certificate errors...
                ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate { return true; });

                /**/

                ApplicationSettings applicationSettings = new ApplicationSettings();

                _arachnodeDAO = new ArachnodeDAO(applicationSettings.ConnectionString);

                _htmlRenderer = new HtmlRenderer(_arachnodeDAO);

                Closed += Renderer_Closed;

                if (_useAxWebBrowser && !DesignMode)
                {
                    object o = axWebBrowser1.GetOcx();

                    IOleObject oleObject = o as IOleObject;

                    oleObject.SetClientSite(this);
                }

                axWebBrowser1.Silent = true;

                if (_useAxWebBrowser)
                {
                    Thread thread = new Thread(() =>
                                                   {
                                                       while (true)
                                                       {
                                                           Thread.Sleep(1000 * 60 * 1);

                                                           if (_stopwatch.Elapsed.TotalMinutes > 1)
                                                           {
                                                               _stopwatch.Reset();
                                                               _stopwatch.Start();

                                                               axWebBrowser1.Stop();

                                                               axWebBrowser1_DocumentComplete(this, null);
                                                           }
                                                       }
                                                   });

                    thread.SetApartmentState(ApartmentState.STA);
                    thread.Start();
                }

                /**/

                //uncomment these to use...
                //_rendererActions.Add(new IFrames());
                //_rendererActions.Add(new Hrefs());
                //_rendererActions.Add(new Inputs());

                _htmlRenderer.DocumentComplete += _htmlParser_DocumentComplete;

                /**/

                if (_debugSingleAbsoluteUri || _debugMultipleAbsoluteUris)
                {
                    return;
                }

                /**/

                #region Default Crawling Thread
                //both should be set to 'false' for default crawling execution...
                if (!_debugSingleAbsoluteUri && !_debugMultipleAbsoluteUris)
                {
                    _stopwatchTotal.Reset();
                    _stopwatchTotal.Start();

                    _thread = new Thread(delegate()
                                             {
                                                 try
                                                 {
                                                     MessageQueue rendererMessageQueue = new MessageQueue(".\\private$\\Renderer_Renderers:" + 0);
                                                     rendererMessageQueue.Formatter = new XmlMessageFormatter(new[] { typeof(RendererMessage) });

                                                     while (rendererMessageQueue.Peek() == null)
                                                     {
                                                         Thread.Sleep(10);
                                                     }

                                                     Message message = rendererMessageQueue.Receive();

                                                     _rendererMessage = (RendererMessage)message.Body;

                                                     /**/

                                                     rendererMessageQueue = new MessageQueue(".\\private$\\Renderer_Renderers:" + _rendererMessage.ThreadNumber);
                                                     rendererMessageQueue.Formatter = new XmlMessageFormatter(new[] { typeof(RendererMessage) });

                                                     _engineMessageQueue = new MessageQueue(".\\private$\\Renderer_Engine:" + _rendererMessage.ThreadNumber);

                                                     /**/

                                                     //remoting code for Marshalling the HTMLDocumentClass...
                                                     BinaryClientFormatterSinkProvider clientProvider = null;
                                                     BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();
                                                     serverProvider.TypeFilterLevel = TypeFilterLevel.Full;

                                                     Hashtable props = new Hashtable();
                                                     props["name"] = "Renderer" + _rendererMessage.ThreadNumber;
                                                     props["portName"] = "Renderer" + _rendererMessage.ThreadNumber;
                                                     props["authorizedGroup"] = WindowsIdentity.GetCurrent().Name;
                                                     //props["typeFilterLevel"] = TypeFilterLevel.Full;

                                                     IpcChannel channel = new IpcChannel(props, clientProvider, serverProvider);

                                                     ChannelServices.RegisterChannel(channel, false);

                                                     RemotingConfiguration.RegisterWellKnownServiceType(typeof(Renderer), "Renderer" + _rendererMessage.ThreadNumber, WellKnownObjectMode.SingleCall);
                                                     RemotingServices.Marshal(this, "Renderer" + _rendererMessage.ThreadNumber);

                                                     /**/

                                                     tsslStatus.Text = ".\\private$\\Renderer_Engine:" + _rendererMessage.ThreadNumber + " Awaiting CrawlRequests...";

                                                     while (true && !_abortThread)
                                                     {
                                                         try
                                                         {
                                                             message = rendererMessageQueue.Receive();

                                                             _stopwatch.Reset();
                                                             _stopwatch.Start();

                                                             _rendererMessage = (RendererMessage)message.Body;
                                                             _htmlRenderer.CrawlRequestTimeoutInMinutes = _rendererMessage.CrawlRequestTimeoutInMinutes;

                                                             tsslStatus.Text = DateTime.Now.ToLongTimeString() + " .\\private$\\Renderer_Engine:" + _rendererMessage.ThreadNumber + " " + _rendererMessage.AbsoluteUri + " TimeTakenToReceiveMessage: " + _stopwatch.Elapsed.TotalSeconds;

                                                             if (!_rendererMessage.Kill)
                                                             {
                                                                 switch (_rendererMessage.RenderAction)
                                                                 {
                                                                     case RenderAction.Render:
                                                                         if (!string.IsNullOrEmpty(_rendererMessage.ProxyServer))
                                                                         {
                                                                             ConnectionProxy.SetConnectionProxy(_rendererMessage.ProxyServer.TrimEnd('/'));
                                                                         }
                                                                         else
                                                                         {
                                                                             ConnectionProxy.RestoreSystemProxy();
                                                                         }

                                                                         if (!string.IsNullOrEmpty(_rendererMessage.Cookie))
                                                                         {
                                                                             //key1=value1;key2=value2;

                                                                             if (!string.IsNullOrEmpty(_rendererMessage.Cookie))
                                                                             {
                                                                                 string[] cookieSplit = _rendererMessage.Cookie.Split(";".ToCharArray());

                                                                                 foreach (string cookieSplit2 in cookieSplit)
                                                                                 {
                                                                                     string[] cookieSplit3 = cookieSplit2.Split("=".ToCharArray());

                                                                                     if (cookieSplit3.Length >= 2)
                                                                                     {
                                                                                         StringBuilder stringBuilder = new StringBuilder();

                                                                                         for (int i = 1; i < cookieSplit3.Length; i++)
                                                                                         {
                                                                                             stringBuilder.Append(cookieSplit3[i] + "=");
                                                                                         }
                                                                                         string value = stringBuilder.ToString().TrimEnd("=".ToCharArray());

                                                                                         InternetSetCookie(_rendererMessage.AbsoluteUri, cookieSplit3[0], cookieSplit3[1]);
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }

                                                                         if (_useAxWebBrowser)
                                                                         {
                                                                             object userAgent = "User-Agent: " + _rendererMessage.UserAgent;
                                                                             object o1 = null;
                                                                             object o2 = null;
                                                                             object o3 = null;
                                                                             DateTime startTime = DateTime.Now;

                                                                             axWebBrowser1.Navigate(_rendererMessage.AbsoluteUri, ref o1, ref o2, ref o3, ref userAgent);

                                                                             if (_modifyDOM)
                                                                             {
                                                                                 bool wasDOMModified = false;

                                                                                 while (axWebBrowser1.ReadyState != tagREADYSTATE.READYSTATE_COMPLETE && DateTime.Now.Subtract(startTime).Duration().TotalMinutes < _rendererMessage.CrawlRequestTimeoutInMinutes)
                                                                                 {
                                                                                     Thread.Sleep(100);

                                                                                     if (axWebBrowser1.ReadyState == tagREADYSTATE.READYSTATE_INTERACTIVE)
                                                                                     {
                                                                                         if (!wasDOMModified)
                                                                                         {
                                                                                             _htmlRenderer.ModifyDOM((IHTMLDocument2)axWebBrowser1.Document, false);

                                                                                             wasDOMModified = true;
                                                                                         }
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                         else
                                                                         {
                                                                             _htmlRenderer.Render(_rendererMessage.AbsoluteUri);
                                                                         }
                                                                         break;
                                                                     case RenderAction.Back:
                                                                         axWebBrowser1.GoBack();
                                                                         break;
                                                                     case RenderAction.Forward:
                                                                         axWebBrowser1.GoForward();
                                                                         break;
                                                                 }

                                                                 try
                                                                 {
                                                                     foreach (Process process in Process.GetProcesses())
                                                                     {
                                                                         if (process.ProcessName.ToLowerInvariant() == "iexplore" ||
                                                                             process.ProcessName.ToLowerInvariant() == "chrome" ||
                                                                             process.ProcessName.ToLowerInvariant() == "vsjitdebugger" ||
                                                                             process.MainWindowTitle.ToLowerInvariant() == "web browser" ||
                                                                             process.MainWindowTitle.ToLowerInvariant() == "renderer" ||
                                                                             process.MainWindowTitle.ToLowerInvariant() == "visual studio just-in-time debugger")
                                                                         {
                                                                             //if (MessageBox.Show("Close? 1", "Arachnode.Renderer", MessageBoxButtons.YesNo) == DialogResult.Yes)
                                                                             //{
                                                                             //    process.Kill();
                                                                             //}
                                                                         }
                                                                     }

                                                                     IntPtr window = WinApis.FindWindowByCaption(IntPtr.Zero, "Web Browser");

                                                                     if (window != IntPtr.Zero)
                                                                     {
                                                                         WinApis.CloseWindow(window);
                                                                     }

                                                                     window = WinApis.FindWindowByCaption(IntPtr.Zero, "Message from webpage");

                                                                     if (window != IntPtr.Zero)
                                                                     {
                                                                         WinApis.CloseWindow(window);
                                                                     }
                                                                 }
                                                                 catch (Exception exception)
                                                                 {
                                                                     //MessageBox.Show(exception.Message);
                                                                     //MessageBox.Show(exception.StackTrace);

                                                                     _arachnodeDAO.InsertException(null, null, exception, false);
                                                                 }
                                                             }
                                                             else
                                                             {
                                                                 //if (MessageBox.Show("Close? 2", "Arachnode.Renderer", MessageBoxButtons.YesNo) == DialogResult.Yes)
                                                                 //{
                                                                 //    Process.GetCurrentProcess().Kill();
                                                                 //}
                                                             }
                                                         }
                                                         catch (Exception exception)
                                                         {
                                                             //MessageBox.Show(exception.Message);
                                                             //MessageBox.Show(exception.StackTrace);

                                                             _arachnodeDAO.InsertException(null, null, exception, false);
                                                         }
                                                     }
                                                 }
                                                 catch (Exception exception)
                                                 {
                                                     //MessageBox.Show(exception.Message);
                                                     //MessageBox.Show(exception.StackTrace);

                                                     _arachnodeDAO.InsertException(null, null, exception, false);
                                                 }
                                             });
Exemplo n.º 27
0
        /// <summary>
        /// Only public method which starts the parsing process
        /// When parsing is done, we receive a DISPID_READYSTATE dispid
        /// in IPropertyNotifySink.OnChanged implementation
        /// </summary>
        /// <param name="Url"></param>
        /// <param name="cookie"></param>
        public void StartParsing(string Url, string cookie)
        {
            IntPtr pUsername = IntPtr.Zero;
            IntPtr pPassword = IntPtr.Zero;

            try
            {
                if (string.IsNullOrEmpty(Url))
                {
                    throw new ApplicationException("Url must have a valid value!");
                }

                //Create a new MSHTML, throws exception if fails
                Type htmldoctype = Type.GetTypeFromCLSID(Iid_Clsids.CLSID_HTMLDocument, true);
                //Using Activator inplace of CoCreateInstance, returns IUnknown
                //which we cast to a IHtmlDocument2 interface
                m_pMSHTML = (IHTMLDocument2)System.Activator.CreateInstance(htmldoctype);

                //Get the IOleObject
                m_WBOleObject = (IOleObject)m_pMSHTML;
                //Set client site
                int iret = m_WBOleObject.SetClientSite(this);

                //Connect for IPropertyNotifySink
                m_WBOleControl = (IOleControl)m_pMSHTML;
                m_WBOleControl.OnAmbientPropertyChange(HTMLDispIDs.DISPID_AMBIENT_DLCONTROL);

                //Get connectionpointcontainer
                IConnectionPointContainer cpCont = (IConnectionPointContainer)m_pMSHTML;
                cpCont.FindConnectionPoint(ref Iid_Clsids.IID_IPropertyNotifySink, out m_WBConnectionPoint);
                //Advice
                m_WBConnectionPoint.Advise(this, out m_dwCookie);

                m_Done = false;
                m_Url  = Url;

                if (!string.IsNullOrEmpty(cookie))
                {
                    m_pMSHTML.cookie = cookie;
                }

                //Set up username and password if provided
                if (!string.IsNullOrEmpty(m_Username))
                {
                    pUsername = Marshal.StringToCoTaskMemAnsi(m_Username);
                    if (pUsername != IntPtr.Zero)
                    {
                        WinApis.InternetSetOption(IntPtr.Zero,
                                                  InternetSetOptionFlags.INTERNET_OPTION_USERNAME,
                                                  pUsername, m_Username.Length);
                    }
                }
                if (!string.IsNullOrEmpty(m_Password))
                {
                    pPassword = Marshal.StringToCoTaskMemAnsi(m_Password);
                    if (pPassword != IntPtr.Zero)
                    {
                        WinApis.InternetSetOption(IntPtr.Zero,
                                                  InternetSetOptionFlags.INTERNET_OPTION_PASSWORD,
                                                  pPassword, m_Password.Length);
                    }
                }
                //Load
                IPersistMoniker persistMoniker = (IPersistMoniker)m_pMSHTML;
                IMoniker        moniker        = null;
                WinApis.CreateURLMoniker(null, m_Url, out moniker);
                if (moniker == null)
                {
                    return;
                }
                IBindCtx bindContext = null;
                WinApis.CreateBindCtx((uint)0, out bindContext);
                if (bindContext == null)
                {
                    return;
                }
                persistMoniker.Load(1, moniker, bindContext, 0);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (pUsername != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(pUsername);
                }
                if (pPassword != IntPtr.Zero)
                {
                    Marshal.FreeCoTaskMem(pPassword);
                }
            }
        }
        /// <summary>
        /// Only public method which starts the parsing process
        /// When parsing is done, we receive a DISPID_READYSTATE dispid
        /// in IPropertyNotifySink.OnChanged implementation
        /// </summary>
        /// <param name="Url"></param>
        /// <param name="cookie"></param>
        public void StartParsing(string Url, string cookie)
        {
            IntPtr pUsername = IntPtr.Zero;
            IntPtr pPassword = IntPtr.Zero;
            try
            {
                if (string.IsNullOrEmpty(Url))
                    throw new ApplicationException("Url must have a valid value!");

                //Create a new MSHTML, throws exception if fails
                Type htmldoctype = Type.GetTypeFromCLSID(Iid_Clsids.CLSID_HTMLDocument, true);
                //Using Activator inplace of CoCreateInstance, returns IUnknown
                //which we cast to a IHtmlDocument2 interface
                m_pMSHTML = (IHTMLDocument2)System.Activator.CreateInstance(htmldoctype);

                //Get the IOleObject
                m_WBOleObject = (IOleObject)m_pMSHTML;
                //Set client site
                int iret = m_WBOleObject.SetClientSite(this);

                //Connect for IPropertyNotifySink
                m_WBOleControl = (IOleControl)m_pMSHTML;
                m_WBOleControl.OnAmbientPropertyChange(HTMLDispIDs.DISPID_AMBIENT_DLCONTROL);

                //Get connectionpointcontainer
                IConnectionPointContainer cpCont = (IConnectionPointContainer)m_pMSHTML;
                cpCont.FindConnectionPoint(ref Iid_Clsids.IID_IPropertyNotifySink, out m_WBConnectionPoint);
                //Advice
                m_WBConnectionPoint.Advise(this, out m_dwCookie);

                m_Done = false;
                m_Url = Url;

                if (!string.IsNullOrEmpty(cookie))
                    m_pMSHTML.cookie = cookie;

                //Set up username and password if provided
                if (!string.IsNullOrEmpty(m_Username))
                {
                    pUsername = Marshal.StringToCoTaskMemAnsi(m_Username);
                    if (pUsername != IntPtr.Zero)
                        WinApis.InternetSetOption(IntPtr.Zero,
                            InternetSetOptionFlags.INTERNET_OPTION_USERNAME,
                            pUsername, m_Username.Length);
                }
                if (!string.IsNullOrEmpty(m_Password))
                {
                    pPassword = Marshal.StringToCoTaskMemAnsi(m_Password);
                    if (pPassword != IntPtr.Zero)
                        WinApis.InternetSetOption(IntPtr.Zero,
                            InternetSetOptionFlags.INTERNET_OPTION_PASSWORD,
                            pPassword, m_Password.Length);
                }
                //Load
                IPersistMoniker persistMoniker = (IPersistMoniker)m_pMSHTML;
                IMoniker moniker = null;
                WinApis.CreateURLMoniker(null, m_Url, out moniker);
                if (moniker == null)
                    return;
                IBindCtx bindContext = null;
                WinApis.CreateBindCtx((uint)0, out bindContext);
                if (bindContext == null)
                    return;
                persistMoniker.Load(1, moniker, bindContext, 0);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (pUsername != IntPtr.Zero)
                    Marshal.FreeCoTaskMem(pUsername);
                if (pPassword != IntPtr.Zero)
                    Marshal.FreeCoTaskMem(pPassword);
            }
        }
Exemplo n.º 29
0
        static void Main(string[] args)
        {
            //            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("http://site.domain.com/operations/reporting/report-run.asp?reportid=720");
            ////webRequest.Proxy = webProxy;

            string appname = Environment.GetCommandLineArgs()[0];

            if (args.Count() < 1)
            {
                Console.WriteLine("Type: \"{0}\" -h for help on usage.\n", appname);
                return;
            }

            if (args.Count() > 0)
            {
                foreach (var s in args)
                {
                    if (s.Contains("-h") || s.Contains("/h") || s.Contains("-?") || s.Contains("/?"))
                    {
                        Console.WriteLine("\nUsage: {0} [-rfupv] <values>\n", appname);
                        Console.WriteLine("\n -r report_link ");
                        Console.WriteLine(" -f output_file ");
                        Console.WriteLine(" -u username   ");
                        Console.WriteLine(" -p password   ");
                        Console.WriteLine(" -t time_delay - seconds to wait before sending key strokes");
                        Console.WriteLine(" -v                  verbose output to console (for debugging)");
                        Console.WriteLine(" -h|?                Display this info and exit.");

                        return;
                    }
                }
            }


            try
            {
                if (args.Any(x => x.Contains("-f")))
                {
                    int i = 0;
                    while (!args[i].Contains("-f"))
                    {
                        i++;
                    }
                    filename = args[i + 1];
                }
                else
                {
                    filename = "report.csv";
                }

                if (args.Any(x => x.Contains("-r")))
                {
                    int i = 0;
                    while (!args[i].Contains("-r"))
                    {
                        i++;
                    }
                    report = args[i + 1];
                }
                else
                {
                    report = "http://site.domain.com/operations/reporting/report-run.asp?reportid=720";
                }

                if (args.Any(x => x.Contains("-u")))
                {
                    int i = 0;
                    while (!args[i].Contains("-u"))
                    {
                        i++;
                    }
                    username = args[i + 1];
                }
                else
                {
                    username = "";
                }

                if (args.Any(x => x.Contains("-p")))
                {
                    int i = 0;
                    while (!args[i].Contains("-p"))
                    {
                        i++;
                    }
                    password = args[i + 1];
                }
                else
                {
                    password = "";
                }

                if (args.Any(x => x.Contains("-t")))
                {
                    int i = 0;
                    while (!args[i].Contains("-t"))
                    {
                        i++;
                    }
                    t = int.Parse(args[i + 1]);
                }
                else
                {
                    t = 5;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                if (ex.InnerException != null)
                {
                    Console.WriteLine(ex.InnerException.Message);
                }
                return;
            }

            ///////////////////////////////

            //////////////////////////////////////////////////////

            Console.WriteLine("start");
            var th = new Thread(() => {
                //WebBrowser

                var wb = new SelfAuthenticatingWebBrowser();        // WebBrowser();



                wb.Show(); Console.WriteLine(wb.DocumentText);
                Console.WriteLine(wb.DocumentText);
                wb.DocumentCompleted += browser_DocumentCompleted;
                wb.NewWindow         += browser_newWindow;
                wb.ControlAdded      += browser_ControlAdded;
                wb.LostFocus         += browser_LostFocus;
                wb.Navigating        += browser_Navigating;
                wb.FileDownload      += browser_FileDownload;
                //wb.Site =  new MySitex();
                //Console.WriteLine(wb.Site.GetService(typeof(IAuthenticateEx)));//wb.Site.Name

                Console.WriteLine(wb.AllowNavigation);
                wb.Navigate("about:blank");

                object obj    = wb.ActiveXInstance;
                IOleObject oc = obj as IOleObject;
                oc.SetClientSite(wb as IOleClientSite);
                //this.Site = this as ISite;
                System.IntPtr ppvServiceProvider;
                IServiceProvider sp = wb as IServiceProvider;
                sp.QueryService(ref SelfAuthenticatingWebBrowser.SID_IAuthenticate, ref SelfAuthenticatingWebBrowser.IID_IAuthenticate, out ppvServiceProvider);


                wb.Navigate(report);
                Application.Run();
            });

            th.SetApartmentState(ApartmentState.STA);
            th.Start();

            Console.WriteLine("end");
        }
Exemplo n.º 30
0
        /// <summary>
        /// Create Webbrowser control and set up it's events
        /// called from OnHandleCreated
        /// Webbrowser control hosting requires an HWND
        /// </summary>
        /// <returns></returns>
        private void InternalCreateWB()
        {
            //Create a new WB, throws exception if fails
            Type webbrowsertype = Type.GetTypeFromCLSID(Iid_Clsids.CLSID_WebBrowser, true);
            //Using Activator inplace of CoCreateInstance, returns IUnknown
            m_WBUnknown = System.Activator.CreateInstance(webbrowsertype);

            //Get the IOleObject
            m_WBOleObject = (IOleObject)m_WBUnknown;
            //Set client site
            int iret = m_WBOleObject.SetClientSite(this);
            //Set hostnames
            iret = m_WBOleObject.SetHostNames("csEXWB", string.Empty);

            //Get client rect
            bool brect = WinApis.GetClientRect(this.Handle, out m_WBRect);
            //Setup H+W
            m_WBRect.Right = m_WBRect.Right - m_WBRect.Left; //W
            m_WBRect.Bottom = m_WBRect.Bottom - m_WBRect.Top; //H
            m_WBRect.Left = 0;
            m_WBRect.Top = 0;

            //Get the IOleInPlaceObject
            m_WBOleInPlaceObject = (IOleInPlaceObject)m_WBUnknown;
            tagRECT trect = new tagRECT();
            WinApis.CopyRect(ref trect, ref m_WBRect);
            //Set WB rects
            iret = m_WBOleInPlaceObject.SetObjectRects(ref m_WBRect, ref trect);

            //INPLACEACTIVATE the WB
            iret = m_WBOleObject.DoVerb((int)OLEDOVERB.OLEIVERB_INPLACEACTIVATE, ref m_NullMsg, this, 0, this.Handle, ref m_WBRect);

            //Get the IWebBrowser2
            m_WBWebBrowser2 = (IWebBrowser2)m_WBUnknown;

            //By default, we handle dragdrops
            m_WBWebBrowser2.RegisterAsDropTarget = false;
            if (!DesignMode)
            {
                //Get connectionpointcontainer
                IConnectionPointContainer cpCont = (IConnectionPointContainer)m_WBUnknown;
                //Find connection point
                Guid guid = typeof(DWebBrowserEvents2).GUID;
                IConnectionPoint m_WBConnectionPoint = null;
                cpCont.FindConnectionPoint(ref guid, out m_WBConnectionPoint);
                //Advice
                m_WBConnectionPoint.Advise(this, out m_dwCookie);

                //Get the IOleComandTarget
                m_WBOleCommandTarget = (IOleCommandTarget)m_WBUnknown;

                //Reguster clipborad format for internal drag drop
                //RegisterClipboardFormatsForDragDrop();
            }

            if (!string.IsNullOrEmpty(m_sUrl))
                this.Navigate(m_sUrl);
            else
                this.Navigate("about:blank");

            //Get the shell embedding, ...
            WBIEServerHandle();
        }