Commit de70686f authored by Alexander Dorofeyev's avatar Alexander Dorofeyev Committed by Alexandre Julliard

devenum: Move locating category key to function, use it ParseDisplayName.

parent cd5fa7de
......@@ -96,6 +96,35 @@ static ULONG WINAPI DEVENUM_ICreateDevEnum_Release(ICreateDevEnum * iface)
return 1; /* non-heap based object */
}
HRESULT DEVENUM_GetCategoryKey(REFCLSID clsidDeviceClass, HKEY *pBaseKey, WCHAR *wszRegKeyName, UINT maxLen)
{
if (IsEqualGUID(clsidDeviceClass, &CLSID_AudioRendererCategory) ||
IsEqualGUID(clsidDeviceClass, &CLSID_AudioInputDeviceCategory) ||
IsEqualGUID(clsidDeviceClass, &CLSID_VideoInputDeviceCategory) ||
IsEqualGUID(clsidDeviceClass, &CLSID_MidiRendererCategory))
{
*pBaseKey = HKEY_CURRENT_USER;
strcpyW(wszRegKeyName, wszActiveMovieKey);
if (!StringFromGUID2(clsidDeviceClass, wszRegKeyName + strlenW(wszRegKeyName), maxLen - strlenW(wszRegKeyName)))
return E_OUTOFMEMORY;
}
else
{
*pBaseKey = HKEY_CLASSES_ROOT;
strcpyW(wszRegKeyName, clsid_keyname);
strcatW(wszRegKeyName, wszRegSeparator);
if (!StringFromGUID2(clsidDeviceClass, wszRegKeyName + CLSID_STR_LEN, maxLen - CLSID_STR_LEN))
return E_OUTOFMEMORY;
strcatW(wszRegKeyName, wszRegSeparator);
strcatW(wszRegKeyName, wszInstanceKeyName);
}
return S_OK;
}
/**********************************************************************
* DEVENUM_ICreateDevEnum_CreateClassEnumerator
*/
......@@ -108,6 +137,7 @@ HRESULT WINAPI DEVENUM_ICreateDevEnum_CreateClassEnumerator(
WCHAR wszRegKey[MAX_PATH];
HKEY hkey;
HKEY hbasekey;
HRESULT hr;
CreateDevEnumImpl *This = (CreateDevEnumImpl *)iface;
TRACE("(%p)->(%s, %p, %x)\n\tDeviceClass:\t%s\n", This, debugstr_guid(clsidDeviceClass), ppEnumMoniker, dwFlags, debugstr_guid(clsidDeviceClass));
......@@ -117,29 +147,9 @@ HRESULT WINAPI DEVENUM_ICreateDevEnum_CreateClassEnumerator(
*ppEnumMoniker = NULL;
if (IsEqualGUID(clsidDeviceClass, &CLSID_AudioRendererCategory) ||
IsEqualGUID(clsidDeviceClass, &CLSID_AudioInputDeviceCategory) ||
IsEqualGUID(clsidDeviceClass, &CLSID_VideoInputDeviceCategory) ||
IsEqualGUID(clsidDeviceClass, &CLSID_MidiRendererCategory))
{
hbasekey = HKEY_CURRENT_USER;
strcpyW(wszRegKey, wszActiveMovieKey);
if (!StringFromGUID2(clsidDeviceClass, wszRegKey + strlenW(wszRegKey), MAX_PATH - strlenW(wszRegKey)))
return E_OUTOFMEMORY;
}
else
{
hbasekey = HKEY_CLASSES_ROOT;
strcpyW(wszRegKey, clsid_keyname);
strcatW(wszRegKey, wszRegSeparator);
if (!StringFromGUID2(clsidDeviceClass, wszRegKey + CLSID_STR_LEN, MAX_PATH - CLSID_STR_LEN))
return E_OUTOFMEMORY;
strcatW(wszRegKey, wszRegSeparator);
strcatW(wszRegKey, wszInstanceKeyName);
}
hr = DEVENUM_GetCategoryKey(clsidDeviceClass, &hbasekey, wszRegKey, MAX_PATH);
if (FAILED(hr))
return hr;
if (RegOpenKeyW(hbasekey, wszRegKey, &hkey) != ERROR_SUCCESS)
{
......@@ -148,7 +158,7 @@ HRESULT WINAPI DEVENUM_ICreateDevEnum_CreateClassEnumerator(
IsEqualGUID(clsidDeviceClass, &CLSID_VideoInputDeviceCategory) ||
IsEqualGUID(clsidDeviceClass, &CLSID_MidiRendererCategory))
{
HRESULT hr = DEVENUM_CreateSpecialCategories();
hr = DEVENUM_CreateSpecialCategories();
if (FAILED(hr))
return hr;
if (RegOpenKeyW(hbasekey, wszRegKey, &hkey) != ERROR_SUCCESS)
......
......@@ -93,6 +93,11 @@ extern CreateDevEnumImpl DEVENUM_CreateDevEnum;
extern ParseDisplayNameImpl DEVENUM_ParseDisplayName;
/**********************************************************************
* Private helper function to get AM filter category key location
*/
HRESULT DEVENUM_GetCategoryKey(REFCLSID clsidDeviceClass, HKEY *pBaseKey, WCHAR *wszRegKeyName, UINT maxLen);
/**********************************************************************
* Global string constant declarations
*/
extern const WCHAR clsid_keyname[6];
......
......@@ -90,11 +90,13 @@ static HRESULT WINAPI DEVENUM_IParseDisplayName_ParseDisplayName(
{
LPOLESTR pszBetween = NULL;
LPOLESTR pszClass = NULL;
IEnumMoniker * pEm = NULL;
MediaCatMoniker * pMoniker = NULL;
CLSID clsidDevice;
HRESULT res = S_OK;
WCHAR wszRegKeyName[MAX_PATH];
HKEY hbasekey;
int classlen;
static const WCHAR wszRegSeparator[] = {'\\', 0 };
TRACE("(%p, %s, %p, %p)\n", pbc, debugstr_w(pszDisplayName), pchEaten, ppmkOut);
......@@ -122,9 +124,7 @@ static HRESULT WINAPI DEVENUM_IParseDisplayName_ParseDisplayName(
if (SUCCEEDED(res))
{
res = DEVENUM_ICreateDevEnum_CreateClassEnumerator((ICreateDevEnum *)(char*)&DEVENUM_CreateDevEnum, &clsidDevice, &pEm, 0);
if (res == S_FALSE) /* S_FALSE means no category */
res = MK_E_NOOBJECT;
res = DEVENUM_GetCategoryKey(&clsidDevice, &hbasekey, wszRegKeyName, MAX_PATH);
}
if (SUCCEEDED(res))
......@@ -132,9 +132,10 @@ static HRESULT WINAPI DEVENUM_IParseDisplayName_ParseDisplayName(
pMoniker = DEVENUM_IMediaCatMoniker_Construct();
if (pMoniker)
{
if (RegCreateKeyW(((EnumMonikerImpl *)pEm)->hkey,
pszBetween,
&pMoniker->hkey) == ERROR_SUCCESS)
strcatW(wszRegKeyName, wszRegSeparator);
strcatW(wszRegKeyName, pszBetween);
if (RegCreateKeyW(hbasekey, wszRegKeyName, &pMoniker->hkey) == ERROR_SUCCESS)
*ppmkOut = (LPMONIKER)pMoniker;
else
{
......@@ -144,9 +145,6 @@ static HRESULT WINAPI DEVENUM_IParseDisplayName_ParseDisplayName(
}
}
if (pEm)
IEnumMoniker_Release(pEm);
CoTaskMemFree(pszClass);
TRACE("-- returning: %x\n", res);
......
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