次の方法で共有


Implementing a Custom Download Manager

The ability to implement a custom download manager was introduced in Microsoft Internet Explorer 5.5. This feature enables you to extend the functionality of Windows 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 can be extended to display a custom user interface. You could, for example, create a download manager that enables you to view MPEG files or launch applications.

A download manager is implemented as a COM object that exposes the IUnknown and IDownloadManager interface. IDownloadManager has only one method, IDownloadManager::Download, which is called by Internet Explorer or 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.

  1. If the IServiceProvider::QueryService method of the IServiceProvider interface is implemented, the WebBrowser application first calls IServiceProvider::QueryService to retrieve an IDownloadManager interface pointer. The following example shows a possible implementation of the IServiceProvider::QueryService method.

    STDMETHODIMP CServiceProvider::QueryService(REFGUID guidService,
                                                REFIID riid,
                                                void **ppv)
    {
        HRESULT hr = E_NOINTERFACE;
    
        if (guidService == SID_SDownloadManager && riid == IID_IDownloadManager)
        {
            // Create new CDownloadMgr object using ATL.
            CComObject<CDownloadMgr>* pDownloadMgr;
            hr = CComObject<CDownloadMgr>::CreateInstance(&pDownloadMgr);
    
            // Query the new CDownloadMgr object for IDownloadManager interface.
            hr = pDownloadMgr->QueryInterface(IID_IDownloadManager, ppv);
        }
    
        return hr;
    }
    
  2. For Microsoft Internet Explorer 6 and later, if the WebBrowser application does not implement the IServiceProvider::QueryService method, or when using Internet Explorer itself for which IServiceProvider::QueryService cannot be implemented, the application checks for the presence of a registry key containing 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
                DownloadUI
    

If the application cannot locate a custom download manager the default download user interface is used.

Reference

IDownloadManager

IDownloadManager::Download