怎样通过COM对象与IE5连接

zlcad 2000-04-28 02:55:00
本人学习IE扩展编程,在软件开发网络上下载了一个IEHelper例子,该实例通过Browser Helper Objects连接到IE,来监视IE的各种活动(实现原理付后)。该程序在vc6上编译通过,在IE4上运行正常,可在IE5上无任何反映。请问各位大侠,是IE5不支持Browser Helper Objects,还是别的原因,还有什么方法可连接到IE5的运行实例上,在那有相应技术资料?请教各位,万分感谢!


IEHelper - How to implement a Browser Helper Object
---------------------------------------------------

1. Introduction

In order to attach to a running instance of Internet Explorer 4.0 (IE4), An application called a "Browser Helper Object" can be used. This application is a DLL that will attach itself to every instance of IE that is executed on the system. IEHelper demonstrates how to create a Browser Helper Object.

When an instance of IE is started, it looks in the registry for CLSIDs stored under the following key:
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects

If this key exists and there are CLSIDs listed under this key, IE will use CoCreateInstance() to try to create an instance of each object listed as a subkey under this key. Note that the CLSID of the object you create must be listed as a subkey and not a named value.


2. Restrictions of Browser Helper Objects

1) The application that you create must be an in-proc server (i.e., DLL)
2) This DLL must implement IObjectWithSite.
3) The IObjectWithSite::SetSite() method must be implemented. It is
through this method that your application receives a pointer to IE's
IUnknown. (IE actually passes a pointer to IWebBrowser2 but the
implementation of SetSite() receives a pointer to IUnknown.) You can
use this IUnknown pointer to automate IE or to sink events from IE.

3. Using IEHelper

To compile and run IEHelper, follow these steps:

1) Compile IEHelper using Visual C++ 5.0 or above. Compiling IEHelper will register the DLL in the registry. The registry script contained in IEHlprObj.rgs will create the necessary registry entries to register IEHelper as an IE4 Browser Helper Object.

2) Each time a new instance of IE4 is started, IEHelper will be loaded. IE will create an instance of each Browser Helper Object listed in the registry every time a new instance of IE is executed. This means that if you have Active Desktop installed, the Browser Helper Objects will be loaded every time you open a folder or change to a new folder as well as when the browser itself is started.

3) View IE4 events in IEHelper's events window.

4) To unregister IEHelper so that it is no longer registered as a Browser Helper Object, run regsvr32 with the following options from the command line: regsvr32 /u IEHelper.dll
...全文
247 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
lingo 2000-05-22
  • 打赏
  • 举报
回复
以下是MSDN上的说明,非常管用,我在IE5成功!位于Knowledge Base/Internet Explore Development/How to Connecting to a running instance of IE
Add references to Shdocvw.dll and Mshtml.dll to the project:


#import "mshtml.h"
#import "shdocvw.dll" exclude("tagREADYSTATE")


Declare an instance of an IShellWindows pointer:

SHDocVw::IShellWindowsPtr m_spSHWinds;


Create an instance of a ShellWindows object:

m_spSHWinds.CreateInstance(__uuidof(SHDocVw::ShellWindows));


Use the ShellWindows object:

void CConnectIEView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();

ASSERT(m_spSHWinds != NULL);

CString strCount;
long nCount = m_spSHWinds->GetCount();

strCount.Format("%i", nCount);
m_strWinCount = strCount;

UpdateData(FALSE);

IDispatchPtr spDisp;
for (long i = 0; i < nCount; i++)
{
_variant_t va(i, VT_I4);
spDisp = m_spSHWinds->Item(va);

SHDocVw::IWebBrowser2Ptr spBrowser(spDisp);
if (spBrowser != NULL)
{
m_ctlListLoc.AddString(spBrowser->GetLocationName());

MSHTML::IHTMLDocument2Ptr spDoc(spBrowser->GetDocument());
if (spDoc != NULL)
{
m_ctlListTitle.AddString(spDoc->Gettitle());
}
}
}
}


The previous method for connecting to a running instance of the Internet Explorer does not work if Shell Integration is not installed or if "Browse in a new process" is selected in Internet Explorer 4.0.
ace 2000-05-04
  • 打赏
  • 举报
回复
Ie5肯定支持,而且比ie4支持的要好
看看你有没有注册正确?
zlcad 2000-05-01
  • 打赏
  • 举报
回复
就是www.csdn.net呀! Visual C++ 部分找源吗。
Marksman 2000-04-29
  • 打赏
  • 举报
回复
拜托软件开发网络在哪里呢?我也想去看一看。

3,245

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧