Commit 82abd743 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

quartz: Simplify FilterMapper3_CreateCategory().

Avoid some unnecessary allocations. Signed-off-by: 's avatarZebediah Figura <z.figura12@gmail.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 228b8b98
......@@ -253,62 +253,44 @@ static ULONG WINAPI FilterMapper3_Release(IFilterMapper3 * iface)
/*** IFilterMapper3 methods ***/
static HRESULT WINAPI FilterMapper3_CreateCategory(
IFilterMapper3 * iface,
REFCLSID clsidCategory,
DWORD dwCategoryMerit,
LPCWSTR szDescription)
static HRESULT WINAPI FilterMapper3_CreateCategory(IFilterMapper3 *iface,
REFCLSID category, DWORD merit, const WCHAR *description)
{
LPWSTR wClsidAMCat = NULL;
LPWSTR wClsidCategory = NULL;
WCHAR wszKeyName[ARRAY_SIZE(wszClsidSlash)-1 + ARRAY_SIZE(wszSlashInstance)-1 + (CHARS_IN_GUID-1) * 2 + 1];
HKEY hKey = NULL;
LONG lRet;
HRESULT hr;
TRACE("(%s, %x, %s)\n", debugstr_guid(clsidCategory), dwCategoryMerit, debugstr_w(szDescription));
hr = StringFromCLSID(&CLSID_ActiveMovieCategories, &wClsidAMCat);
WCHAR guidstr[39], keypath[93];
HKEY key;
LONG ret;
if (SUCCEEDED(hr))
{
hr = StringFromCLSID(clsidCategory, &wClsidCategory);
}
TRACE("iface %p, category %s, merit %#x, description %s.\n", iface,
debugstr_guid(category), merit, debugstr_w(description));
if (SUCCEEDED(hr))
{
lstrcpyW(wszKeyName, wszClsidSlash);
lstrcatW(wszKeyName, wClsidAMCat);
lstrcatW(wszKeyName, wszSlashInstance);
lstrcatW(wszKeyName, wClsidCategory);
StringFromGUID2(category, guidstr, ARRAY_SIZE(guidstr));
wcscpy(keypath, L"CLSID\\{da4e3da0-d07d-11d0-bd50-00a0c911ce86}\\Instance\\");
wcscat(keypath, guidstr);
lRet = RegCreateKeyExW(HKEY_CLASSES_ROOT, wszKeyName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL);
hr = HRESULT_FROM_WIN32(lRet);
}
if ((ret = RegCreateKeyExW(HKEY_CLASSES_ROOT, keypath, 0, NULL, 0, KEY_WRITE, NULL, &key, NULL)))
return HRESULT_FROM_WIN32(ret);
if (SUCCEEDED(hr))
if ((ret = RegSetValueExW(key, L"FriendlyName", 0, REG_SZ,
(const BYTE *)description, (wcslen(description) + 1) * sizeof(WCHAR))))
{
lRet = RegSetValueExW(hKey, wszFriendlyName, 0, REG_SZ, (const BYTE*)szDescription, (lstrlenW(szDescription) + 1) * sizeof(WCHAR));
hr = HRESULT_FROM_WIN32(lRet);
RegCloseKey(key);
return HRESULT_FROM_WIN32(ret);
}
if (SUCCEEDED(hr))
if ((ret = RegSetValueExW(key, L"CLSID", 0, REG_SZ, (const BYTE *)guidstr, sizeof(guidstr))))
{
lRet = RegSetValueExW(hKey, wszClsidName, 0, REG_SZ, (LPBYTE)wClsidCategory, (lstrlenW(wClsidCategory) + 1) * sizeof(WCHAR));
hr = HRESULT_FROM_WIN32(lRet);
RegCloseKey(key);
return HRESULT_FROM_WIN32(ret);
}
if (SUCCEEDED(hr))
if ((ret = RegSetValueExW(key, L"Merit", 0, REG_DWORD, (const BYTE *)&merit, sizeof(DWORD))))
{
lRet = RegSetValueExW(hKey, wszMeritName, 0, REG_DWORD, (LPBYTE)&dwCategoryMerit, sizeof(dwCategoryMerit));
hr = HRESULT_FROM_WIN32(lRet);
RegCloseKey(key);
return HRESULT_FROM_WIN32(ret);
}
RegCloseKey(hKey);
CoTaskMemFree(wClsidCategory);
CoTaskMemFree(wClsidAMCat);
return hr;
RegCloseKey(key);
return S_OK;
}
static HRESULT WINAPI FilterMapper3_UnregisterFilter(
......
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