根据Internet Explorer_Server窗口得到IHtmlDocument2接口
来源:互联网 发布:mysql建数据库语句 编辑:程序博客网 时间:2024/05/21 19:26
作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站
代码很少,自己看
#include <mshtml.h>
#include <atlbase.h>
#include <oleacc.h>
BOOL CALLBACK EnumChildProc(HWND hwnd,LPARAM lParam)
{
TCHAR buf[100];
::GetClassName( hwnd, (LPTSTR)&buf, 100 );
if ( _tcscmp( buf, _T("Internet Explorer_Server") ) == 0 ) \
{
*(HWND*)lParam = hwnd;
return FALSE;
}
else
return TRUE;
};
//You can store the interface pointer in a member variable
//for easier access
void CDlg::OnGetDocInterface(HWND hWnd)
{
CoInitialize( NULL );
// Explicitly load MSAA so we know if it's installed
HINSTANCE hInst = ::LoadLibrary( _T("OLEACC.DLL") );
if ( hInst != NULL )
{
if ( hWnd != NULL )
{
HWND hWndChild=NULL;
// Get 1st document window
::EnumChildWindows( hWnd, EnumChildProc, (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;
CComQIPtr<IHTMLWindow2> spWin;
spDoc->get_Script( &spDisp );
spWin = spDisp;
spWin->get_document( &spDoc.p );
// Change background color to red
spDoc->put_bgColor( CComVariant("red") );
}
}
} // else document not ready
} // else Internet Explorer is not running
::FreeLibrary( hInst );
} // else Active Accessibility is not installed
CoUninitialize();
}
- 根据Internet Explorer_Server窗口得到IHtmlDocument2接口
- 根据Internet Explorer_Server窗口得到IHtmlDocument2接口(IE编程)
- 根据Internet Explorer_Server窗口得到IHtmlDocument2
- 如果知道“Internet Explorer_Server”窗口去获取IWebbrowser2接口
- 已知IWebBrowser2接口,如何获得其Internet Explorer_Server窗口句柄?
- 已知IE窗口的句柄,如何由此得到IHTMLdocument2接口?
- 如何从Internet Explorer_Server窗口句柄获得IHTMLDocument
- Internet Explorer_Server内容获取
- Internet Explorer_Server内容获取
- IHTMLDocument2接口
- IHTMLDocument2接口
- IHTMLDocument2接口
- Ihtmldocument2接口
- Internet Explorer_Server 分析利器(下载)
- Internet Explorer_Server类是个什么类
- 从一个窗口句柄获取IWebBrowser2和IHTMLDocument2接口
- 从一个窗口句柄获取IWebBrowser2和IHTMLDocument2接口
- 从一个窗口句柄获取IWebBrowser2和IHTMLDocument2接口
- 1、Struts2概述与MVC模式
- 概要设计模板
- Debian 6用Qemu安装Windows XP、98和Wine运行Windows软件
- delegate及 lamda表达式
- 计数排序
- 根据Internet Explorer_Server窗口得到IHtmlDocument2接口
- 如何免费下载百度文库文档
- 冲出UAC-解决Win UAC问题的编程经验
- java null
- 讲座宣传
- 一个AT指令的困惑(AT+CMGR)
- PostgreSQL 数据类型手册【serial, timestamp,text....】
- poj 1995 快速幂取模
- linux下vi命令大全