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: ...@@ -325,38 +325,37 @@ lend:
/*************************************************************** /***************************************************************
* DMOGetName (MSDMO.@) * 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]; WCHAR szguid[64];
HKEY hrkey = 0; HKEY hrkey, hkey;
HKEY hkey = 0;
static const INT max_name_len = 80;
DWORD count;
LONG ret; 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 (RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0, KEY_READ, &hrkey))
if (ERROR_SUCCESS != ret) return E_FAIL;
goto lend;
ret = RegOpenKeyExW(hrkey, GUIDToString(szguid, clsidDMO), 0, KEY_READ, &hkey); ret = RegOpenKeyExW(hrkey, GUIDToString(szguid, clsidDMO), 0, KEY_READ, &hkey);
if (ERROR_SUCCESS != ret) RegCloseKey(hrkey);
goto lend; if (ret)
return E_FAIL;
count = max_name_len * sizeof(WCHAR); ret = RegQueryValueExW(hkey, NULL, NULL, NULL, (LPBYTE)name, &count);
ret = RegQueryValueExW(hkey, NULL, NULL, NULL, (LPBYTE) szName, &count); RegCloseKey(hkey);
TRACE(" szName=%s\n", debugstr_w(szName)); if (!ret && count > 1)
lend: {
if (hkey) TRACE("name=%s\n", debugstr_w(name));
RegCloseKey(hrkey); return S_OK;
if (hkey) }
RegCloseKey(hkey);
return HRESULT_FROM_WIN32(ret); name[0] = 0;
return S_FALSE;
} }
/************************************************************************** /**************************************************************************
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0); 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_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_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) static void test_DMOUnregister(void)
{ {
...@@ -54,7 +55,23 @@ static void test_DMOUnregister(void) ...@@ -54,7 +55,23 @@ static void test_DMOUnregister(void)
ok(hr == S_FALSE, "got 0x%08x\n", hr); 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) START_TEST(msdmo)
{ {
test_DMOUnregister(); 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