用API获得Internet Explorer_Server类的HTML

落花浮王杯 提交于 2019-11-26 19:03:28

  

  首先要找到含有Internet Explorer_Server类句柄,

  HTMLDocumentClass  result = (HTMLDocumentClass)documentFromDOM(hWnd.ToInt32());

  result.activeElement.innerHTML就得到所有HTML

 

  

private static IHTMLDocument2 documentFromDOM(int hWnd)
        {
             IHTMLDocument2 document=null;

            int lRes=0;
            int lngMsg = NativeMethods.RegisterWindowMessage("WM_HTML_GETOBJECT");
            Guid IID_IHTMLDocument = new Guid("626FC520-A41E-11CF-A731-00A0C9082637");
            if (lngMsg != 0)
            {
                NativeMethods.SendMessageTimeout(hWnd, lngMsg, 0, 0, NativeMethods.SMTO_ABORTIFHUNG, 1000, ref lRes);
                if (!(bool)(lRes == 0))
                {
                    int hr = NativeMethods.ObjectFromLresult(lRes, ref IID_IHTMLDocument, 0, ref document);
                    if ((bool)(document == null))
                    {
                        MessageBox.Show("No IHTMLDocument Found!", "Warning");
                    }
                }
            }


            return document;
        }

 

 

转载于:https://www.cnblogs.com/hubj/archive/2010/05/15/1735947.html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!