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

This commit is contained in:
Nikolay Sivov 2015-04-22 14:31:42 +03:00 committed by Alexandre Julliard
parent c954d50b16
commit 6238adc817
2 changed files with 37 additions and 21 deletions

View File

@ -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;
RegCloseKey(hrkey);
if (ret)
return E_FAIL;
count = max_name_len * sizeof(WCHAR);
ret = RegQueryValueExW(hkey, NULL, NULL, NULL, (LPBYTE) szName, &count);
ret = RegQueryValueExW(hkey, NULL, NULL, NULL, (LPBYTE)name, &count);
RegCloseKey(hkey);
TRACE(" szName=%s\n", debugstr_w(szName));
lend:
if (hkey)
RegCloseKey(hrkey);
if (hkey)
RegCloseKey(hkey);
if (!ret && count > 1)
{
TRACE("name=%s\n", debugstr_w(name));
return S_OK;
}
return HRESULT_FROM_WIN32(ret);
name[0] = 0;
return S_FALSE;
}
/**************************************************************************

View File

@ -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();
}