描述:
问题是:
当点击网页中的一个链接时(文件链接或者asp,php等),如何让下载软件自动运行(代替原来IE的下载),并获得该链接,进而开始下载。假设下载功能已经开发完毕。
就像FlashGet那样的。
解决方案1:
就像"影印传送带"的IEHelp*.dll
解决方案2: Microsoft Internet Explorer uses two mechanisms for registering new URL protocol handlers. The first method is to register a URL protocol and its associated application so that all attempts to navigate to a URL using that protocol launch the application (for example, registering applications to handle mailto: or news: URLs). The second method uses the Asynchronous Pluggable Protocols API, which allows you to define new protocols by mapping the protocol scheme to a class.
For information on how to register an application for a particular URL protocol, see Appendix B: Registering an Application to a URL Protocol.
上面的内容来自MSDN:Pluggable Protocols Overview
可以在MSDN找到:Appendix B: Registering an Application to a URL Protocol.这篇文章,
看懂这两篇文章,应该可以满足你的要求。
class ATL_NO_VTABLE CDownloadMgr:
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CDownloadMgr, &CLSID_DownloadMgr>,
public IDownloadManager
{
DECLARE_REGISTRY_RESOURCEID(...)
DECLARE_NOT_AGGREAGET(CDownloadMgr)
BEGIN_COM_MAP(CDownloadMgr)
COM_INTERFACE_ENTRY(IDownloadManager)
END_COM_MAP()
public:
STDMETHOD(Download)(IMoniker *pmk,
IBindCtx *pbc,
DWORD dwBindVerb,
LONG grfBINDF,
BINDINFO *pBindInfo,
LPCOLESTR pszHeaders,
LPCOLESTR pszRedir,
UINT uiCP
);
}