1、用WebBrowser做程序,但是点击网页中的连接(比如连到“http://www.xxx.com/yyy.zip”)就打开了IE默认的下载文件对话框,如何截获这个事件,并知道文件的URL(就是上面的http://www.xxx.com/yyy.zip)。
2、有时连接是这样的“http://www.xxx.com/yyy.asp?id=1234567”,也会打开IE默认的下载文件对话框,这个事件能截获并知道文件的URL么?。
2、有时连接是这样的“http://www.xxx.com/yyy.asp?id=1234567”,也会打开IE默认的下载文件对话框,这个事件能截获并知道文件的URL么?。
解决方案 »
- 请问读取文件的问题
- 这样的结果,怎么查询啊??
- Microsoft.XMLHTTP 返回的数据,如何用dom语句控制啊?
- 请问用VB操作WMI的话先地在工程里怎么操作?还要装什么软件吗?
- 求助:TreeView和datagrid左右拖动问题
- 我有一个vb写的串口通讯的程序,程序在运行了大约10多个小时后,出现如下情况,请问我如何解决?
- 在类中如何使用Timer来处理事件?
- 请教: .rm文件用什么来播放?
- vb中怎么样打开、读写二进制文件?
- 用sql-dmo备份数据库,备份文件如何写到局域网内的机子(目录非共享)上?
- 在VB中自定义了一个资源文件。如果让他不释放以硬盘,在内存中运行!
- 急急!!请各位帮忙解决这个问题。
Applies To
This article was previously published under Q327865
IN THIS TASK
SUMMARY
Requirements
Download Headers and Libraries
Code Sample
REFERENCES
SUMMARY
This step-by-step article describes how to implement a custom download manager in Microsoft Internet Explorer 5.5 and Microsoft Internet Explorer 6. With this feature, you can extend the functionality of Internet Explorer and WebBrowser applications by implementing a Component Object Model (COM) object to handle the file download process. By implementing a custom download manager, your WebBrowser application or Internet Explorer can be extended to display a custom user interface. A download manager is implemented as a COM object that exposes the IUnknown interface and the IDownloadManager interface. IDownloadManager has only one method, IDownloadManager::Download. The IDownloadManager::Download method is called by Internet Explorer or by a WebBrowser application to download a file. When a file is selected for download in a WebBrowser application, the custom download manager is accessed in one of two ways:
In Internet Explorer 5.5, if the IServiceProvider::QueryService method of the IServiceProvider interface is implemented, the WebBrowser application first calls IServiceProvider::QueryService to retrieve an IDownloadManager interface pointer. For a possible implementation of the IServiceProvider::QueryService method, see the "Code Sample" section of this article.-or-
For Internet Explorer 6 and later, if the WebBrowser application does not implement the IServiceProvider::QueryService method, or when you use Internet Explorer itself (IServiceProvider::QueryService cannot be implemented in Internet Explorer), the application checks for a registry value that contains the class identifier (CLSID) of the download manager COM object. The CLSID can be provided in either of the following registry values:
\HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\DownloadUI
\HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\DownloadUIFor a detailed implementation, see the "Code Sample" section of the article.back to the top
Requirements
The following list outlines the recommended hardware, software, network infrastructure, and service packs that you need for this procedure:
Microsoft Visual Studio 6
Microsoft Internet Explorer 5.5 Service Pack 2 and later
back to the top
Download Headers and Libraries
You must download the Internet Explorer headers and libraries for both Internet Explorer 5.5 and Internet Explorer 6, and then add them to the include and library directories. To do this, visit the following Microsoft Developer Network (MSDN) Web sites:For Internet Explorer 5.5
http://msdn.microsoft.com/downloads/samples/internet/default.asp?url=/Downloads/samples/Internet/libraries/ie55_lib/default.aspFor Internet Explorer 6
http://msdn.microsoft.com/downloads/samples/internet/default.asp?url=/Downloads/samples/Internet/libraries/ie6_lib/default.aspback to the top
Code Sample
Internet Explorer 5.5// This is a custom download manager implementation for Internet Explorer 5.5 SP2.
#include "downloadmgr.h"
STDMETHOD(QueryService)(REFGUID guidService,REFIID riid,void** ppv)
{
HRESULT hr = E_NOINTERFACE;
if (guidService == SID_SDownloadManager && riid == IID_IDownloadManager)
{
// Create a new CDownloadMgr object by using ATL.
CComObject<CDownloadMgr>* pDownloadMgr;
hr = CComObject<CDownloadMgr>::CreateInstance(&pDownloadMgr);
// Query the new CDownloadMgr object for the IDownloadManager interface.
hr = pDownloadMgr->QueryInterface(IID_IDownloadManager, ppv);
// Call the Download method. // -or-
// Call the Download method directly if you implement it in this class.
// Download(NULL,NULL,0,0,NULL,NULL,NULL,0);
// hr = S_OK;
} return hr;
}
Internet Explorer 6// This is the custom download manager implementation for Internet Explorer 6 or later.
// In the .h file of the COM DLL.
#include "downloadmgr.h"
STDMETHOD(Download)(IMoniker* pmk,
IBindCtx* pbc,
DWORD dwBindVerb,
LONG grfBINDF,
BINDINFO* pBindInfo,
LPCOLESTR pszHeaders,
LPCOLESTR pszRedir,
UINT uiCP );
// In the .cpp file.
STDMETHODIMP CDownload::Download(IMoniker* pmk,
IBindCtx* pbc,
DWORD dwBindVerb,
LONG grfBINDF,
BINDINFO* pBindInfo,
LPCOLESTR pszHeaders,
LPCOLESTR pszRedir,
UINT uiCP )
{
::MessageBox(NULL,"Download","Download Manager",MB_OK);
return S_OK;
}
back to the top
REFERENCES
For more information, visit the following MSDN Web site:
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/ext/overview/downloadmgr.asp