Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
inet
active_desktop
active_scrptng
asp.components
asp.db
asp.general
comctl32
comp.packaging
components.dev
dbweb
dhtml_editing
docobjects
html_authoring
html_objmodel
iis
iis.ftp
iis.security
iis.smtp_nntp
indexserver
misc
mshtml_hosting
scripting.jscript
scripting.vbscript
sdk_setup
shell_objmodel
urlmonikers
webbrowser_ctl
wininet
  
 
date: Wed, 22 Aug 2007 13:51:06 -0000,    group: microsoft.public.inetsdk.programming.urlmonikers        back       


BindToStorage sets IStream pointer to NULL when working in async mode   
Hi there,

I'm trying to asynchronously get a resource using URL Monikers; I
can't use WinInet functions as I need to access other protocols than
http and ftp.

What i've done so far is:

1. Implementented IBindStatusCallback as follow:

class CBSCallback :
	public IBindStatusCallback
{
...
STDMETHOD(GetBindInfo)(DWORD *pgrfBINDF, BINDINFO *pbindInfo){
	ATLTRACE("*************** CBSCallback::GetBindInfo\n");

	*pgrfBINDF = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE |
BINDF_PULLDATA;
        pbindInfo->cbSize = sizeof(BINDINFO);
        pbindInfo->szExtraInfo = NULL;
        memset(&pbindInfo->stgmedData, 0, sizeof(STGMEDIUM));
        pbindInfo->grfBindInfoF = 0;
        pbindInfo->dwBindVerb = BINDVERB_GET;
        pbindInfo->szCustomVerb = NULL;
        return S_OK;
}

STDMETHOD(OnDataAvailable)(DWORD grfBSCF, DWORD dwSize, FORMATETC
*pformatetc, STGMEDIUM *pstgmed){
	ATLTRACE("*************** CBSCallback::OnDataAvailable\n");
	return S_OK;
}
...
}


2. Used URL Monikers as follow:

// Pointers that need cleanup
IMoniker *pMoniker  = NULL;
IBindCtx *pBindCtx  = NULL;
IStream  *pStream   = NULL;

// Callback object
CBSCallback         *bsCallback    = NULL;
IBindStatusCallback *pCallback     = NULL;

HRESULT hr;

// Get URL
LPCTSTR szURL = _T("http://www.google.com/");

// Get IBindStatusCallback interface
bsCallback = new CBSCallback();
hr = bsCallback->QueryInterface(__uuidof(IBindStatusCallback), (void
**) &pCallback);
if(pCallback == NULL) { ... }

// Create URLMoniker
hr = CreateURLMonikerEx(NULL, T2CW(szURL), &pMoniker, URL_MK_UNIFORM);
if(hr != S_OK) { ... }

// Create BindCtx
hr = CreateAsyncBindCtx(0, pCallback, NULL, &pBindCtx);
if(hr != S_OK) { ... }

// Set bind options
BIND_OPTS2 options;
ZeroMemory( &options, sizeof(&options));
options.cbStruct = sizeof(BIND_OPTS2);
options.grfMode  = STGM_READ | STGM_SHARE_DENY_NONE | STGM_SIMPLE;
options.grfFlags = 0;
hr = pBindCtx->SetBindOptions(&options);
if(hr != S_OK) { ... }

// Register callback
hr = RegisterBindStatusCallback(pBindCtx, pCallback, 0, 0L);
if(hr != S_OK) { ... }

// Bind moniker to storage
hr = pMoniker->BindToStorage(pBindCtx, 0, IID_IStream, (void**)
&pStream);
if(hr !=  S_OK && hr != MK_S_ASYNCHRONOUS) { ... }


3. This is what happens while BindToStorage() is executed:
- CBSCallback::GetBindInfo() gets called
- CBSCallback::OnStartBinding() gets called
- Some dlls get loaded (mswsock.dll, hnetcfg.dll, rasapi32.dll, etc)
so I guess the download started just fine

CBSCallback::OnDataAvailable() never gets called and pStream is NULL.
How do I access the data that the URL Moniker is downloading?

Thank you for your attention.
date: Wed, 22 Aug 2007 13:51:06 -0000   author:   Rhemax

Re: BindToStorage sets IStream pointer to NULL when working in async mode   
On Aug 22, 4:51 pm, Rhemax  wrote:
> Hi there,
> ...
> Thank you for your attention.

Found the problem. After the call to BindToStorage() I had to start a
message pump as the code was executed in a worker thread.
date: Wed, 22 Aug 2007 16:01:11 -0000   author:   Rhemax

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us