devenum: Return S_FALSE from CreateClassEnumerator() if no devices exist.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=46316
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2019-04-05 19:41:13 -05:00 committed by Alexandre Julliard
parent 541c8d271e
commit e0da0b777a
2 changed files with 23 additions and 1 deletions

View file

@ -862,7 +862,23 @@ static HRESULT WINAPI DEVENUM_ICreateDevEnum_CreateClassEnumerator(
else if (IsEqualGUID(class, &CLSID_VideoInputDeviceCategory))
register_avicap_devices();
return create_EnumMoniker(class, out);
if (SUCCEEDED(hr = create_EnumMoniker(class, out)))
{
IMoniker *mon;
hr = IEnumMoniker_Next(*out, 1, &mon, NULL);
if (hr == S_OK)
{
IMoniker_Release(mon);
IEnumMoniker_Reset(*out);
}
else
{
IEnumMoniker_Release(*out);
*out = NULL;
}
}
return hr;
}
/**********************************************************************

View file

@ -69,6 +69,7 @@ static void test_devenum(IBindCtx *bind_ctx)
WCHAR *displayname;
VARIANT var;
HRESULT hr;
int count;
hr = CoCreateInstance(&CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC,
&IID_ICreateDevEnum, (LPVOID*)&create_devenum);
@ -105,6 +106,8 @@ static void test_devenum(IBindCtx *bind_ctx)
if (hr == S_OK)
{
count = 0;
while (IEnumMoniker_Next(enum_moniker, 1, &moniker, NULL) == S_OK)
{
hr = IMoniker_GetDisplayName(moniker, NULL, NULL, &displayname);
@ -136,8 +139,11 @@ static void test_devenum(IBindCtx *bind_ctx)
CoTaskMemFree(displayname);
IPropertyBag_Release(prop_bag);
IMoniker_Release(moniker);
count++;
}
IEnumMoniker_Release(enum_moniker);
ok(count > 0, "CreateClassEnumerator() returned S_OK but no devices were enumerated.\n");
}
}