- char str[128];
- GetClassName(hwnd,str,sizeof(str));//获取类名
- if(strcmp(str,"Internet Explorer_Server")==0)
- {
- CoInitialize( NULL );
- HINSTANCE hInst = ::LoadLibrary( _T("OLEACC.DLL") );
- CComPtr<IHTMLDocument2> spDoc;
- LRESULT lRes;
- UINT nMsg = RegisterWindowMessage( _T("WM_HTML_GETOBJECT") );
- SendMessageTimeout( hwnd, nMsg, 0L, 0L, SMTO_ABORTIFHUNG, 1000, (DWORD*)&lRes
通过窗口句柄,获取IE控件里的内容(获取IHTMLDocument2和HTML)
最新推荐文章于 2022-04-12 18:26:32 发布
这段代码演示了如何通过窗口句柄获取类名为'Internet Explorer_Server'的控件,进一步得到IHTMLDocument2接口,从而访问HTML内容。首先调用GetClassName检查窗口类名,然后利用WM_HTML_GETOBJECT消息和 OleAcc.dll 库获取IHTMLDocument2指针,最后保存并显示HTML内容。
摘要由CSDN通过智能技术生成