Creates a blocking stream object from a URL.
HRESULT URLOpenBlockingStream(
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
);
This function returns the same values as IBindHost::MonikerBindToStorage.
Immediately on receiving the interface pointer returned by this function, the caller can download data from the Internet by calling ISequentialStream::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.
Windows NT: Use version 5.0 or later.
Windows: Unsupported.
Windows CE: Unsupported.
Header: Declared in urlmon.h.
IBindStatusCallback, IBindStatusCallback::OnProgress, IStream, ISequentialStream, ISequentialStream::Read