locked
IE8 downloader and files greater then 4GB RRS feed

  • Question

  • I create my downloader for IE8. First I have create downloader for smaller then 4GB files. 


    //.h file:
    class IEDownloader:	public IBindStatusCallback
    {
    ...
    }
    
    //c++ file
    
    STDMETHODIMP IEDownloader::OnProgress(ULONG progress, ULONG progress_max,<br/>									ULONG status_code, LPCWSTR status_text)
    {	
    	switch (status_code)
    	{
    	case BINDSTATUS_CACHEFILENAMEAVAILABLE:
    		{
                     //geting name and size
    		} break;
    
    	case BINDSTATUS_ENDDOWNLOADDATA:
    		{
                     //gownloading is finish
    		} break;
    	}
    	return S_OK;
    }
    
    STDMETHODIMP IEDownloader::GetBindInfo(DWORD *info_elements, BINDINFO *bind_info)<br/>{
    	*info_elements = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE | 
    		BINDF_PULLDATA | BINDF_GETNEWESTVERSION | BINDF_NO_UI;
    	return S_OK;
    }
    
    STDMETHODIMP IEDownloader::OnDataAvailable(DWORD data_type, DWORD size, <br/>	FORMATETC *format_etc, STGMEDIUM *stg_med)
    {
     //here I copy new data to my file
    }
    

    to register this object I create simple function:

    void IEDownloader::StartDownload(IBindCtx* bind_ctx)<br/>{
    	IMoniker* moniker = NULL;
    	if (FAILED(CreateURLMonikerEx(NULL, _url.c_str(), &moniker, URL_MK_UNIFORM)))
    		{
    			CreateURLMoniker(NULL, _url.c_str(), &moniker))
     		}
    	RegisterBindStatusCallback(bind_ctx, this, NULL, 0))
    	CComPtr< IStream > stream;
    	moniker->BindToStorage(bind_ctx, 0, IID_IStream, (void**) &stream);
    	//waiting for downloaded file
    }
    

    This code work good!
    Then I try to add support for files greater 4GB:

    class IEDownloader:	public IBindStatusCallbackEx
    ...
    
    STDMETHODIMP IEDownloader::GetBindInfoEx (DWORD *pgrfBINDF,
    										  BINDINFO* pbindinfo,
    										  DWORD* pgrfBINDF2,
    										  DWORD* pdwReserved)
    {
    	*pgrfBINDF2 = BINDF2_READ_DATA_GREATER_THAN_4GB;
    	return GetBindInfo(pgrfBINDF, pbindinfo);
    } 
    
    STDMETHODIMP IEDownloader::OnProgress(ULONG progress, ULONG progress_max,
    									ULONG status_code, LPCWSTR status_text)
    {	
    	switch (status_code)
    	{
    	//...
    	case BINDSTATUS_64BIT_PROGRESS:
    		{
    			//output status_text
    		}
    	}
    	return S_OK;
    }
    
    void IEDownloader::StartDownload(IBindCtx* bind_ctx)
    {
    	IMoniker* moniker = NULL;
    	if (FAILED(CreateURLMonikerEx(NULL, _url.c_str(), &moniker, URL_MK_UNIFORM)))
    		{
    			CreateURLMoniker(NULL, _url.c_str(), &moniker))
     		}
    	RegisterBindStatusCallback(bind_ctx, this, NULL, 0))
    
    	//replace IStream to IStorage
    	CComPtr< IStorage > pStorage;
    	moniker->BindToStorage(bind_ctx, NULL, IID_IStorage, (void**)&pStorage);
    
    	//waiting for downloaded file
    }
    
    STDMETHODIMP IEDownloader::OnDataAvailable(DWORD data_type, DWORD size, 
    	FORMATETC *format_etc, STGMEDIUM *stg_med)
    {
     //here I copy new data to my file
    }
    

    Small file has downloaded ok, but if I try to download a file greater then 4GB OnProgress with BINDSTATUS_64BIT_PROGRESS has called once on starting, and OnDataAvailable hasn't called.

    Tuesday, December 29, 2009 10:36 AM

Answers