如题,各位帮忙整整
解决方案 »
- 建立空文档失败
- 为什么会重复定义
- [求助:新手第一次]过一段时间就要被老大逼着写NDIS驱动,请有经验的朋友推荐几本入门书好吗
- _RecordsetPtr记录集
- 如何用InstallShield安装打印驱动?
- 有nt/win2000下服务程序经验的朋友花几分钟关注一下,等了2天了
- 请问:保存数据到一个自建类型的文件中,取数据,画图,显示。这个过程大概是怎样的?(分数可加到300,急)
- 哪有“0-9”,“.”发音文件下载
- 做动画时我用了画了擦再画,出现闪动太大怎么处理?怎样理解多线程编程?
- 新时期遇到老问题(在先等待)
- 关于菜单更新的一个问题
- SetWindowLong 的问题 第三个参数转换出错
GetDocument 取文档接口, 再取地址 比较就OK具体可以参看MSDN的
HOWTO: Connecting to a Running Instance of Internet Explorer
如遨游,世界之窗浏览器,一个IE窗口可以包容了多个页面。
有可能打开了多个IE窗口,每个IE窗口又有多个页面,查看IE的标题好像解决不了问题获取IE的运行实例,然后逐一判断网址应该可以解决问题。
4楼能提供资料么?HOWTO: Connecting to a Running Instance of Internet Explorer
http://topic.csdn.net/u/20080706/16/fecdf89b-1738-4fcb-b921-8a9548a901c7.htmlMSDN6.0
mk:@MSITStore:E:\Program%20Files\Microsoft%20Visual%20Studio\MSDN98\98VS\2052\kb.chm::/Source/ie_dev/q176792.htmHOWTO: Connecting to a Running Instance of Internet Explorer
Last reviewed: February 6, 1998
Article ID: Q176792
The information in this article applies to:
Microsoft Internet Explorer (Programming), versions 4.0, 4.01
Internet Client SDK, version 4.0, 4.01
SUMMARY
It is possible to connect to a running instance of Internet Explorer 4.0 (IE4) using the SHDocVw.ShellWindows collection. MORE INFORMATION
Normally, an application connects to a running instance of another application using the Running Object table. Because Internet Explorer 4.0 does not register itself in the running object table, another method is necessary. The ShellWindows collection is described in the Internet Client SDK as follows: The ShellWindows object represents a collection of the open windows that belong to the shell. In fact, this collection contains references to Internet Explorer as well as other windows belonging to the shell, such as the Windows Explorer. The following Visual Basic code obtains a reference to the ShellWindows collection. The collection is enumerated and the LocationName for each object added to a list box. If the document associated with the object is of type HTMLDocument (a Web Page), the title for the page is added to another list box. In order to run the following code, it is necessary to add a reference to Shdocvw.dll and Mshtml.dll to the Visual Basic project:
Dim SWs As New SHDocVw.ShellWindows
Dim IE As SHDocVw.InternetExplorer Private Sub Form_Load()
Dim Doc
List1.Clear
List2.Clear Text1.Text = SWs.count For Each IE In SWs
List1.AddItem IE.LocationName Set Doc = IE.Document
If TypeOf Doc Is HTMLDocument Then
'if this is an HTML page, display the title
'may or may not be the same as LocationName
List2.AddItem Doc.Title
End If
Next
End Sub
In C++, a connection can be accomplished in roughly the same way. Visual C++ Native Com Support is used here for the sake of brevity.
Add references to Shdocvw.dll and Mshtml.dll to the project:
#import "mshtml.dll"
#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.
If these factors cannot be controlled, there is still one possible method that may work. A browser helper object can be written to register Internet Explorer 4.0 in the running object table (ROT). There are many implementations possible here depending on how the application is to determine the instance of Internet Explorer with which to connect. This is just one possible solution: The browser helper object, having access to the object model of the instance of Explorer that launched it, would determine if this is the instance of the browser that should be registered in the running object table. The interface that the consumer is interested in can be registered in the ROT with the RegisterActiveObject function and a dummy CLSID that the consumer will recognize. Another solution, that would allow multiple instances of the explorer to be registered in the ROT, would be to have the Browser Helper object compose an Item moniker based on a GUID and piece of data unique to each instance of Internet Explorer. The moniker would be registered in the ROT with the IRunningObjectTable::Register method. Again, the consumer would have to know how recognize this moniker. REFERENCES
The Internet Client SDK; search on Internet Tools and Technologies - Windows Shell API For additional information, please see the following article(s) in the Microsoft Knowledge Base:
ARTICLE-ID: Q179230
TITLE : FILE: IEHelper-Attaching to IE4 using a Browser Helper Object
(c) Microsoft Corporation 1997, All Rights Reserved. Contributions by Robert Duke, Microsoft Corporation
--------------------------------------------------------------------------------Additional query words: helper connect
Keywords : InetSDKShellObjMod kbcode
Technology : kbInetDev kbole
Version : WINDOWS:4.0
Platform : WINDOWS
Issue type : kbhowto
THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Last reviewed: February 6, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.