根据Internet Explorer_Server窗口得到IHtmlDocument2接口(IE编程)
来源:互联网 发布:西方的没落 知乎 编辑:程序博客网 时间:2024/05/22 06:49
原文转载:http://www.cnblogs.com/chenzhifei/archive/2008/11/12/1332300.html
原文中代码编译不成功,其中有修改的地方标红。
#include <mshtml.h>#include <atlbase.h>#include <oleacc.h>
<pre name="code" class="cpp">IHTMLDocument2* GetDocInterface(HWND hWnd){CoInitialize(NULL);IHTMLDocument2* pDoc2 = NULL;// Explicitly load MSAA so we know if it's installedHINSTANCE hInst = ::LoadLibrary(_T("OLEACC.DLL"));if (hInst != NULL){if (hWnd != NULL){HWND hWndChild = NULL;// Get 1st document window//::EnumChildWindows(hWnd, EnumChildProc, (LPARAM)&hWndChild);EnumWindows(EnumProc, (LPARAM)&hWndChild);if (hWndChild){CComPtr<IHTMLDocument2> spDoc;LRESULT lRes;UINT nMsg = ::RegisterWindowMessage(_T("WM_HTML_GETOBJECT"));::SendMessageTimeout(hWndChild, nMsg, 0L, 0L, SMTO_ABORTIFHUNG, 1000, (DWORD*)&lRes);LPFNOBJECTFROMLRESULT pfObjectFromLresult = (LPFNOBJECTFROMLRESULT)::GetProcAddress(hInst, _T("ObjectFromLresult"));if (pfObjectFromLresult != NULL){HRESULT hr;hr = (*pfObjectFromLresult)(lRes, IID_IHTMLDocument, 0, (void**)&spDoc);if (SUCCEEDED(hr)){CComPtr<IDispatch> spDisp; // 源代码为CComPtr spDisp;CComQIPtr<IHTMLWindow2> spWin;// 源代码为CComQIPtr spWin; spDoc->get_Script(&spDisp);spWin = spDisp;spWin->get_document(&pDoc2);}}} // else document not ready} // else Internet Explorer is not running::FreeLibrary(hInst);} // else Active Accessibility is not installedCoUninitialize();return pDoc2;}
更多详细内容转载:http://www.cnblogs.com/chenzhifei/archive/2008/11/12.html
0 0
- 根据Internet Explorer_Server窗口得到IHtmlDocument2接口(IE编程)
- 根据Internet Explorer_Server窗口得到IHtmlDocument2接口
- 根据Internet Explorer_Server窗口得到IHtmlDocument2
- 已知IE窗口的句柄,如何由此得到IHTMLdocument2接口?
- 如果知道“Internet Explorer_Server”窗口去获取IWebbrowser2接口
- 已知IWebBrowser2接口,如何获得其Internet Explorer_Server窗口句柄?
- 开源小工具一:获取客户端内嵌IE控件(Internet Explorer_Server)的URL
- 如何从Internet Explorer_Server窗口句柄获得IHTMLDocument
- 获取ie窗口的IHTMLDocument2对象
- Internet Explorer_Server内容获取
- Internet Explorer_Server内容获取
- IHTMLDocument2接口
- IHTMLDocument2接口
- IHTMLDocument2接口
- Ihtmldocument2接口
- Internet Explorer_Server 分析利器(下载)
- Internet Explorer_Server类是个什么类
- 也谈根据IE窗口句柄hWnd获得IWebBrowser接口
- html打开中文乱码
- 辅助Praat进行标注的工具
- mysql 关键字 保留字
- 解决Tomcat7“At least one JAR was scanned for TLDs yet contained no TLDs”问题
- java.lang.NoSuchMethodError: com.opensymphony.xwork2.util.ValueStack.findValue(Ljava/lang/String;Lja
- 根据Internet Explorer_Server窗口得到IHtmlDocument2接口(IE编程)
- 属性页对话框 去掉下面的一排按钮
- Exchange2010---反垃圾邮件配置
- 用递归方法求n!。
- 基础总结篇之一:Activity生命周期
- Git Gui for Windows的建库、克隆(clone)、上传(push)、下载(pull)、合并
- iOS之UIWindow、UINavigationController与UITabBarController的区别
- POJ 1019 Number Sequence (规律题)
- 算法学习(Java语言描述) -- 简单选择排序