static HRESULT bind_to_object(DocHost *This, IMoniker *mon, LPCWSTR url, IBindCtx *bindctx, IBindStatusCallback *callback) { WCHAR schema[30]; DWORD schema_len; HRESULT hres; static const WCHAR httpW[] = {'h','t','t','p',0}; static const WCHAR httpsW[] = {'h','t','t','p','s',0}; static const WCHAR ftpW[]= {'f','t','p',0}; if(mon) { IMoniker_AddRef(mon); }else { hres = create_moniker(url, &mon); if(FAILED(hres)) return hres; } CoTaskMemFree(This->url); hres = IMoniker_GetDisplayName(mon, 0, NULL, &This->url); if(FAILED(hres)) FIXME("GetDisplayName failed: %08x\n", hres); IBindCtx_RegisterObjectParam(bindctx, (LPOLESTR)SZ_HTML_CLIENTSITE_OBJECTPARAM, (IUnknown*)CLIENTSITE(This)); hres = CoInternetParseUrl(This->url, PARSE_SCHEMA, 0, schema, sizeof(schema)/sizeof(schema[0]), &schema_len, 0); if(SUCCEEDED(hres) && (!strcmpW(schema, httpW) || !strcmpW(schema, httpsW) || !strcmpW(schema, ftpW))) { hres = http_load_hack(This, mon, callback, bindctx); }else { IUnknown *unk = NULL; hres = IMoniker_BindToObject(mon, bindctx, NULL, &IID_IUnknown, (void**)&unk); if(SUCCEEDED(hres)) { hres = S_OK; if(unk) IUnknown_Release(unk); }else if(try_application_url(url)) { hres = S_OK; }else { FIXME("BindToObject failed: %08x\n", hres); } } IMoniker_Release(mon); return S_OK; }
static HRESULT bind_to_object(DocHost *This, IMoniker *mon, LPCWSTR url, IBindCtx *bindctx, IBindStatusCallback *callback) { IUnknown *unk = NULL; WCHAR *display_name; HRESULT hres; if(mon) { IMoniker_AddRef(mon); }else { hres = create_moniker(url, &mon); if(FAILED(hres)) return hres; } hres = IMoniker_GetDisplayName(mon, 0, NULL, &display_name); if(FAILED(hres)) { FIXME("GetDisplayName failed: %08x\n", hres); return hres; } hres = set_dochost_url(This, display_name); CoTaskMemFree(display_name); if(FAILED(hres)) return hres; IBindCtx_RegisterObjectParam(bindctx, (LPOLESTR)SZ_HTML_CLIENTSITE_OBJECTPARAM, (IUnknown*)&This->IOleClientSite_iface); hres = IMoniker_BindToObject(mon, bindctx, NULL, &IID_IUnknown, (void**)&unk); if(SUCCEEDED(hres)) { hres = S_OK; if(unk) IUnknown_Release(unk); }else if(try_application_url(url)) { hres = S_OK; }else { FIXME("BindToObject failed: %08x\n", hres); } IMoniker_Release(mon); return S_OK; }