用API获得Internet Explorer_Server类的HTML

  

  首先要找到含有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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值