Commit 6238adc8 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

msdmo: Fix DMOGetName() error handling and error values.

parent c954d50b
......@@ -325,38 +325,37 @@ lend:
/***************************************************************
* DMOGetName (MSDMO.@)
*
* Get DMP Name from the registry
* Get DMO Name from the registry
*/
HRESULT WINAPI DMOGetName(REFCLSID clsidDMO, WCHAR szName[])
HRESULT WINAPI DMOGetName(REFCLSID clsidDMO, WCHAR name[])
{
static const INT max_name_len = 80*sizeof(WCHAR);
DWORD count = max_name_len;
WCHAR szguid[64];
HKEY hrkey = 0;
HKEY hkey = 0;
static const INT max_name_len = 80;
DWORD count;
HKEY hrkey, hkey;
LONG ret;
TRACE("%s\n", debugstr_guid(clsidDMO));
TRACE("%s %p\n", debugstr_guid(clsidDMO), name);
ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0, KEY_READ, &hrkey);
if (ERROR_SUCCESS != ret)
goto lend;
if (RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0, KEY_READ, &hrkey))
return E_FAIL;
ret = RegOpenKeyExW(hrkey, GUIDToString(szguid, clsidDMO), 0, KEY_READ, &hkey);
if (ERROR_SUCCESS != ret)
goto lend;
count = max_name_len * sizeof(WCHAR);
ret = RegQueryValueExW(hkey, NULL, NULL, NULL, (LPBYTE) szName, &count);
TRACE(" szName=%s\n", debugstr_w(szName));
lend:
if (hkey)
RegCloseKey(hrkey);
if (hkey)
if (ret)
return E_FAIL;
ret = RegQueryValueExW(hkey, NULL, NULL, NULL, (LPBYTE)name, &count);
RegCloseKey(hkey);
return HRESULT_FROM_WIN32(ret);
if (!ret && count > 1)
{
TRACE("name=%s\n", debugstr_w(name));
return S_OK;
}
name[0] = 0;
return S_FALSE;
}
/**************************************************************************
......
......@@ -25,6 +25,7 @@
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
static const GUID GUID_unknowndmo = {0x14d99047,0x441f,0x4cd3,{0xbc,0xa8,0x3e,0x67,0x99,0xaf,0x34,0x75}};
static const GUID GUID_unknowncategory = {0x14d99048,0x441f,0x4cd3,{0xbc,0xa8,0x3e,0x67,0x99,0xaf,0x34,0x75}};
static const GUID GUID_wmp1 = {0x13a7995e,0x7d8f,0x45b4,{0x9c,0x77,0x81,0x92,0x65,0x22,0x57,0x63}};
static void test_DMOUnregister(void)
{
......@@ -54,7 +55,23 @@ static void test_DMOUnregister(void)
ok(hr == S_FALSE, "got 0x%08x\n", hr);
}
static void test_DMOGetName(void)
{
WCHAR name[80];
HRESULT hr;
hr = DMOGetName(&GUID_unknowndmo, NULL);
ok(hr == E_FAIL, "got 0x%08x\n", hr);
/* no such DMO */
name[0] = 'a';
hr = DMOGetName(&GUID_wmp1, name);
ok(hr == E_FAIL, "got 0x%08x\n", hr);
ok(name[0] == 'a', "got %x\n", name[0]);
}
START_TEST(msdmo)
{
test_DMOUnregister();
test_DMOGetName();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment