# URLOpenBlockingStream

Creates a blocking stream object from a URL.

(

LPUNKNOWN pCaller, | // Caller’s controlling IUnknown
LPCWSTR szURL, | // URL to be converted to stream
LPSTREAM *ppStream, | // Stream object’s IStream
DWORD dwResv, | // Reserved for future use
LPBINDSTATUSCALLBACK lpfnCB | // Caller’s IBindStatusCallback
); |

Parameters

pCaller
  [in] Pointer to the caller’s controlling IUnknown. If the caller is not an ActiveX component, this value may be set to NULL.
szURL
  [out] The URL to be converted to a stream object. Cannot be NULL.
ppStream
  [out] Pointer to the IStream interface pointer on the stream object created by this function.
dwResv
  [in] Reserved for future use; must be zero.
lpfnCB
  [in] Pointer to the IBindStatusCallback interface pointer on the caller. Can be NULL.

Return Values

This function returns the same values as IBindHost::MonikerBindToStorage.

Remarks

Immediately on receiving the interface pointer returned by this function, the caller can download data from the Internet by calling IStream::Read. This call blocks until enough data is available. The following code fragment is a typical implementation of such a call:

    IStream *pStream
    URLOpenStream( 0, L"http://www.msn.com/", &pStream, 0, 0);
    char buffer[0x100];
    DWORD dwGot;
    HRESULT hr = NOERROR;
    do {
        hr = pStream->Read( buffer, sizeof(buffer), &dwGot );

        .. do something with contents of buffer ...
    } while( SUCCEEDED(hr) );

If pCaller is non-NULL, the caller is a COM object that is contained in another component, such as an ActiveX Control in the context of an HTML page.In this case, the function attempts the download in the context of the ActiveX client framework and allows the caller's container to receive callbacks on the progress of the download.

URLOpenBlockingStream calls the caller’s IBindStatusCallback::OnProgress method on some connection activity, including the arrival of data ( IBindStatusCallback::OnDataAvailable is never called for this purpose). Implementing IBindStatusCallback::OnProgress allows a caller to provide a mechanism for monitoring the progress of download operations.It also allows downloads to be canceled by returning E_ABORT from the OnProgress call.

See Also

IBindStatusCallback, IBindStatusCallback::OnProgress, IStream, IStream::Read