コード例 #1
0
ファイル: ImgSrcExtractor.cs プロジェクト: drupii/imageraker
        // document를 일반적으로 가져올 수 없는 경우 (security issue) 이렇게 가져옴.
        public static IHTMLDocument2[] GetHtmlDocumentsByOle(IHTMLDocument2 doc)
        {
            try
            {
                ExceptionTester.Instance.Throw("gethtmlbyole");

                List <IHTMLDocument2> docs = new List <IHTMLDocument2>();

                // add main doc
                docs.Add(doc);

                //get the OLE container from the window's parent
                IOleContainer oc = doc as IOleContainer;                      //OC ALLOC

                //get the OLE enumerator for the embedded objects
                int          hr = 0;
                IEnumUnknown eu;
                hr = oc.EnumObjects(tagOLECONTF.OLECONTF_EMBEDDINGS, out eu);                 //EU ALLOC

                Guid      IID_IWebBrowser2 = typeof(SHDocVw.IWebBrowser2).GUID;
                object    pUnk             = null;
                int       fetched          = 0;
                const int MAX_FETCH_COUNT  = 1;

                for (int i = 0; eu.Next(MAX_FETCH_COUNT, out pUnk, out fetched) == hr; i++)
                {
                    //QI pUnk for the IWebBrowser2 interface
                    SHDocVw.IWebBrowser2 brow = pUnk as SHDocVw.IWebBrowser2;

                    if (brow != null)
                    {
                        IHTMLDocument2 d = brow.Document as IHTMLDocument2;
                        //	Logger.Log("wb found. doc's url: {0}", d.url);

                        // if we found document, repeat recursively
                        IHTMLDocument2[] docs2 = GetHtmlDocumentsByOle(d);

                        foreach (IHTMLDocument2 doc2 in docs2)
                        {
                            docs.Add(doc2);
                        }
                    }
                }

                Marshal.ReleaseComObject(eu);                                                 //EU FREE

                return(docs.ToArray());
            }
            catch (Exception e)
            {
                Logger.Warn("cannt get html doc by ole! {0}", e.Message);

                return(new IHTMLDocument2[] { });
            }
        }
コード例 #2
0
        public static LightWeightHTMLDocument[] GetLightWeightDocumentForFrames(IHTMLDocument2 htmlDocument)
        {
            ArrayList frameLightWeightDocuments = new ArrayList();

            // Get the IOleContainer for the for the html document (this requires that
            // the document is the root document in the browser)
            IOleContainer oleContainer = (IOleContainer)htmlDocument;
            IEnumUnknown  enumUnknown;

            // Enumerate the controls in the browser
            oleContainer.EnumObjects(OLECONTF.EMBEDDINGS, out enumUnknown);

            // Iterate through the controls
            object unknown;

            for (int i = 0; HRESULT.S_OK == enumUnknown.Next(1, out unknown, IntPtr.Zero); i++)
            {
                // Only subframes should cast to IWebBrowser2
                IWebBrowser2 webBrowser = unknown as IWebBrowser2;

                // Since it is a subframe, we can also get the base frame implementation for it
                IHTMLFrameBase frameBase = unknown as IHTMLFrameBase;

                // It's a frame, add this to the list!
                if (webBrowser != null)
                {
                    try
                    {
                        IHTMLDocument2 frameDocument = webBrowser.Document as IHTMLDocument2;

                        if (frameDocument != null)
                        {
                            LightWeightHTMLDocument document = LightWeightHTMLDocument.FromIHTMLDocument2(frameDocument, frameDocument.url, frameBase.name);
                            if (document != null)
                            {
                                frameLightWeightDocuments.Add(document);
                            }
                        }
                    }
                    catch (InvalidCastException)
                    {
                        string html = "<HTML></HTML>";
                        LightWeightHTMLDocument document = LightWeightHTMLDocument.FromString(html, webBrowser.LocationURL, webBrowser.LocationURL, true);
                        if (document != null)
                        {
                            frameLightWeightDocuments.Add(document);
                        }
                    }
                }
            }
            return((LightWeightHTMLDocument[])frameLightWeightDocuments.ToArray(typeof(LightWeightHTMLDocument)));
        }
コード例 #3
0
		public int GetContainer(out IOleContainer ppContainer)
		{
			ppContainer = null;
			return HRESULT.E_NOINTERFACE;
		}
コード例 #4
0
 HRESULT IOleClientSite.GetContainer(out IOleContainer container)
 {
     Debug.WriteLineIf(AxHTraceSwitch.TraceVerbose, "in getContainer");
     container = host.GetParentContainer();
     return(HRESULT.S_OK);
 }
コード例 #5
0
 HRESULT IOleClientSite.GetContainer(out IOleContainer container)
 {
     container = Host.GetParentContainer();
     return(HRESULT.S_OK);
 }
コード例 #6
0
ファイル: HTMLParser.cs プロジェクト: cnboker/autorobo
 int IOleClientSite.GetContainer(out IOleContainer ppContainer)
 {
     ppContainer = null;
     return(Hresults.E_NOTIMPL);
 }
コード例 #7
0
ファイル: HtmlSite.cs プロジェクト: gahadzikwa/GAPP
        public int GetContainer(out IOleContainer ppContainer)
        {

            ppContainer = (IOleContainer)this;
            return HRESULT.S_OK;
        }
コード例 #8
0
 /// <summary>
 /// Returns the object's IOleContainer.  Indicate container doesn't support this interface.
 /// </summary>
 int IOleClientSite.GetContainer(out IOleContainer ppContainer)
 {
     ppContainer = null;
     return(HRESULT.E_NOINTERFACE);
 }
コード例 #9
0
        /// <summary>
        /// Returns a pointer to the container's IOleContainer interface. Used
        /// primarily for OLE linking so we don't support it since MSHTML will
        /// not initiate any OLE linking.
        /// </summary>
        public int GetContainer(out IOleContainer ppContainer)
        {
            // log access to method
            LOG("IOleClientSite", "GetContainer");

            ppContainer = null;
            return HRESULT.E_NOINTERFACE;
        }
コード例 #10
0
 public int GetContainer(out IOleContainer ppContainer)
 {
     ppContainer = null;
     return(HRESULT.E_NOINTERFACE);
 }
コード例 #11
0
ファイル: Win32.cs プロジェクト: teknologika/ITiN
        internal static void EnumIWebBrowser2Interfaces(IWebBrowser2Processor processor)
        {
            IEnumUnknown  eu;
            IOleContainer oc = processor.HTMLDocument() as IOleContainer;
            int           hr = oc.EnumObjects(tagOLECONTF.OLECONTF_EMBEDDINGS, out eu);

            Marshal.ThrowExceptionForHR(hr);

            try
            {
                object    pUnk;
                int       fetched;
                const int MAX_FETCH_COUNT = 1;

                // get the first embedded object
                // pUnk alloc
                hr = eu.Next(MAX_FETCH_COUNT, out pUnk, out fetched);
                Marshal.ThrowExceptionForHR(hr);

                while (hr == 0)
                {
                    // Query Interface pUnk for the IWebBrowser2 interface
                    IWebBrowser2 brow = pUnk as IWebBrowser2;

                    try
                    {
                        if (brow != null)
                        {
                            processor.Process(brow);
                            if (!processor.Continue())
                            {
                                break;
                            }
                            // free brow
                            Marshal.ReleaseComObject(brow);
                        }
                    }
                    catch
                    {
                        if (brow != null)
                        {
                            // free brow
                            Marshal.ReleaseComObject(brow);
                        }
                        // pUnk free
                        Marshal.ReleaseComObject(pUnk);
                    }

                    // pUnk free
                    Marshal.ReleaseComObject(pUnk);

                    // get the next embedded object
                    // pUnk alloc
                    hr = eu.Next(MAX_FETCH_COUNT, out pUnk, out fetched);
                    Marshal.ThrowExceptionForHR(hr);
                }
            }
            finally
            {
                // eu free
                Marshal.ReleaseComObject(eu);
            }
        }
コード例 #12
0
 public void GetContainer(out IOleContainer ppContainer)
 {
     ppContainer = (IOleContainer)this;
 }
コード例 #13
0
        public int GetContainer([MarshalAs(UnmanagedType.Interface), Out] out IOleContainer ppContainer)
        {
            ppContainer = null;

            return(HRESULT.E_NOINTERFACE);
        }
コード例 #14
0
 int IOleClientSite.GetContainer(out IOleContainer ppContainer)
 {
     ppContainer = null;
     return(0);
 }
コード例 #15
0
 int IOleClientSite.GetContainer(out IOleContainer ppContainer)
 {
     ppContainer = null;
     return Hresults.E_NOTIMPL;
 }
コード例 #16
0
 public void GetContainer(out IOleContainer container)
 {
     throw new NotSupportedException();
 }
コード例 #17
0
 /// <summary>
 /// Returns the object's IOleContainer.  Indicate container doesn't support this interface.
 /// </summary>
 int IOleClientSite.GetContainer(out IOleContainer ppContainer)
 {
     ppContainer = null;
     return HRESULT.E_NOINTERFACE;
 }
コード例 #18
0
 public int GetContainer(out IOleContainer ppContainer)
 {
     ppContainer = (IOleContainer)this;
     return(HRESULT.S_OK);
 }
コード例 #19
0
 /// <summary>
 /// Returns the object's IOleContainer.  Indicate container doesn't support this interface.
 /// </summary>
 int IOleClientSite.GetContainer(out IOleContainer ppContainer)
 {
     LOG("IOleClientSite", "GetContainer");
     ppContainer = null;
     return HRESULT.E_NOINTERFACE;
 }