diff --git a/dlls/ole32/itemmoniker.c b/dlls/ole32/itemmoniker.c index 111b111a1ab..19876aa3638 100644 --- a/dlls/ole32/itemmoniker.c +++ b/dlls/ole32/itemmoniker.c @@ -462,33 +462,31 @@ static HRESULT WINAPI ItemMonikerImpl_BindToObject(IMoniker* iface, /****************************************************************************** * ItemMoniker_BindToStorage ******************************************************************************/ -static HRESULT WINAPI ItemMonikerImpl_BindToStorage(IMoniker* iface, - IBindCtx* pbc, - IMoniker* pmkToLeft, - REFIID riid, - VOID** ppvResult) +static HRESULT WINAPI ItemMonikerImpl_BindToStorage(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, REFIID riid, + void **ppvResult) { - ItemMonikerImpl *This = impl_from_IMoniker(iface); - HRESULT res; - IOleItemContainer *poic=0; + ItemMonikerImpl *moniker = impl_from_IMoniker(iface); + IOleItemContainer *container; + HRESULT hr; - TRACE("(%p,%p,%p,%s,%p)\n",iface,pbc,pmkToLeft,debugstr_guid(riid),ppvResult); + TRACE("%p, %p, %p, %s, %p.\n", iface, pbc, pmkToLeft, debugstr_guid(riid), ppvResult); - *ppvResult=0; + *ppvResult = 0; - if(pmkToLeft==NULL) + if (!pmkToLeft) return E_INVALIDARG; - res=IMoniker_BindToObject(pmkToLeft,pbc,NULL,&IID_IOleItemContainer,(void**)&poic); + hr = IMoniker_BindToObject(pmkToLeft, pbc, NULL, &IID_IOleItemContainer, (void **)&container); + if (SUCCEEDED(hr)) + { + if (FAILED(hr = set_container_lock(container, pbc))) + WARN("Failed to lock container, hr %#x.\n", hr); - if (SUCCEEDED(res)){ - - res=IOleItemContainer_GetObjectStorage(poic,This->itemName,pbc,riid,ppvResult); - - IOleItemContainer_Release(poic); + hr = IOleItemContainer_GetObjectStorage(container, moniker->itemName, pbc, riid, ppvResult); + IOleItemContainer_Release(container); } - return res; + return hr; } /****************************************************************************** diff --git a/dlls/ole32/tests/moniker.c b/dlls/ole32/tests/moniker.c index 7d4c8224ad3..231551b244e 100644 --- a/dlls/ole32/tests/moniker.c +++ b/dlls/ole32/tests/moniker.c @@ -380,7 +380,7 @@ static HRESULT WINAPI test_item_container_GetObject(IOleItemContainer *iface, LP static HRESULT WINAPI test_item_container_GetObjectStorage(IOleItemContainer *iface, LPOLESTR item, IBindCtx *pbc, REFIID riid, void **obj) { - return E_NOTIMPL; + return 0x8bee0001; } static HRESULT WINAPI test_item_container_IsRunning(IOleItemContainer *iface, LPOLESTR item) @@ -2235,6 +2235,9 @@ todo_wine hr = IMoniker_BindToStorage(moniker, bindctx, NULL, &IID_IUnknown, (void **)&unknown); ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + hr = IMoniker_BindToStorage(moniker, bindctx, &container_moniker->IMoniker_iface, &IID_IUnknown, (void **)&unknown); + ok(hr == 0x8bee0001, "Unexpected hr %#x.\n", hr); + /* ParseDisplayName() */ hr = IMoniker_ParseDisplayName(moniker, bindctx, NULL, displayname, &eaten, &moniker2); ok(hr == MK_E_SYNTAX, "Unexpected hr %#x.\n", hr);