Internet Explorer_Server内容获取

首先这里假设你已经获取到Internet Explorer_Server窗口的句柄,假设为hwndIE:HWND。
头文件
#include <mshtml.h>    
#include <atlbase.h>    
#include <oleacc.h>   
#include <string>   
#include <comdef.h>   
using std::string;
VOID GetStr(HWND hwndIE)
{
CoInitialize(NULL);  
CComPtr<IHTMLDocument2> pDoc2;  
string strTemp = "";  
HINSTANCE hinst = LoadLibraryA("OLEACC.DLL");  
if(hinst != NULL) {  
LRESULT lres;  
UINT unMsg = RegisterWindowMessageA("WM_HTML_GETOBJECT");  
SendMessageTimeoutA(hwndIE, unMsg, 0L, 0L, SMTO_ABORTIFHUNG, 1000, (PDWORD_PTR)&lres);  
LPFNOBJECTFROMLRESULT pfObjectFromLresult=(LPFNOBJECTFROMLRESULT)::GetProcAddress(hinst, "ObjectFromLresult");  
if(pfObjectFromLresult != NULL) {  
HRESULT hres;  
hres=(*pfObjectFromLresult)(lres,IID_IHTMLDocument2,0,(void**)&pDoc2);  
if(SUCCEEDED(hres)) 
{  
CComPtr<IHTMLElement> pHtmlElem;  
hres = pDoc2->get_body(&pHtmlElem);  
BSTR bstrText = NULL;  
pHtmlElem->get_innerText(&bstrText);  
_bstr_t _bstrTemp(bstrText, false);  
strTemp=(char*)_bstrTemp;  
}  
}  
FreeLibrary(hinst);  
}  


CoUninitialize(); 
}
好了,现在strTemp中已经包含了Internet Explorer_Server窗口的内容了。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值