hlink: Return correct requested interface from HlinkCreateFromMoniker().

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2022-04-11 11:40:32 +03:00 committed by Alexandre Julliard
parent bbb9c273d2
commit 19f802c091
2 changed files with 24 additions and 8 deletions

View File

@ -49,15 +49,15 @@ HRESULT WINAPI HlinkCreateFromMoniker( IMoniker *pimkTrgt, LPCWSTR pwzLocation,
IUnknown* piunkOuter, REFIID riid, void** ppvObj)
{
IHlink *hl = NULL;
HRESULT r;
HRESULT hr;
TRACE("%p %s %s %p %li %p %s %p\n", pimkTrgt, debugstr_w(pwzLocation),
debugstr_w(pwzFriendlyName), pihlsite, dwSiteData, piunkOuter,
debugstr_guid(riid), ppvObj);
r = CoCreateInstance(&CLSID_StdHlink, piunkOuter, CLSCTX_INPROC_SERVER, riid, (LPVOID*)&hl);
if (FAILED(r))
return r;
hr = CoCreateInstance(&CLSID_StdHlink, piunkOuter, CLSCTX_INPROC_SERVER, &IID_IHlink, (LPVOID*)&hl);
if (FAILED(hr))
return hr;
IHlink_SetMonikerReference(hl, HLINKSETF_LOCATION | HLINKSETF_TARGET, pimkTrgt, pwzLocation);
@ -66,11 +66,10 @@ HRESULT WINAPI HlinkCreateFromMoniker( IMoniker *pimkTrgt, LPCWSTR pwzLocation,
if (pihlsite)
IHlink_SetHlinkSite(hl, pihlsite, dwSiteData);
*ppvObj = hl;
hr = IHlink_QueryInterface(hl, riid, ppvObj);
IHlink_Release(hl);
TRACE("Returning %lx\n",r);
return r;
return hr;
}
/***********************************************************************

View File

@ -2607,6 +2607,22 @@ static void test_HlinkUpdateStackItem(void)
CHECK_CALLED(HLF_UpdateHlink);
}
static void test_HlinkCreateFromMoniker(void)
{
IPersistStream *stream;
IMoniker *moniker;
HRESULT hr;
hr = CreateItemMoniker(L"1", L"1", &moniker);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = HlinkCreateFromMoniker(moniker, L"1", L"a", NULL, 0, NULL, &IID_IPersistStream, (void **)&stream);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
IPersistStream_Release(stream);
IMoniker_Release(moniker);
}
START_TEST(hlink)
{
CoInitialize(NULL);
@ -2627,6 +2643,7 @@ START_TEST(hlink)
test_StdHlink();
test_Hlink_Navigate();
test_HlinkUpdateStackItem();
test_HlinkCreateFromMoniker();
CoUninitialize();
}