#include "objbase.h"
#include "wine/unicode.h"
#include "wine/debug.h"
-#include "initguid.h"
#include "dmo.h"
WINE_DEFAULT_DEBUG_CHANNEL(msdmo);
return lpwstr;
}
+static HRESULT string_to_guid(const WCHAR *string, GUID *guid)
+{
+ WCHAR buffer[39];
+ buffer[0] = '{';
+ strcpyW(buffer + 1, string);
+ buffer[37] = '}';
+ buffer[38] = 0;
+ return CLSIDFromString(buffer, guid);
+}
+
static BOOL IsMediaTypeEqual(const DMO_PARTIAL_MEDIATYPE* mt1, const DMO_PARTIAL_MEDIATYPE* mt2)
{
{
IEnumDMOImpl* lpedmo;
HRESULT hr;
- LONG ret;
*obj = NULL;
lpedmo->dwFlags = dwFlags;
lpedmo->cInTypes = cInTypes;
lpedmo->cOutTypes = cOutTypes;
+ lpedmo->hkey = NULL;
hr = dup_partial_mediatype(pInTypes, cInTypes, &lpedmo->pInTypes);
if (FAILED(hr))
/* If not filtering by category enum from media objects root */
if (IsEqualGUID(guidCategory, &GUID_NULL))
{
- if ((ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0, KEY_READ, &lpedmo->hkey)))
- hr = HRESULT_FROM_WIN32(ret);
+ RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0, KEY_READ, &lpedmo->hkey);
}
else
{
WCHAR szKey[MAX_PATH];
wsprintfW(szKey, szCat3Fmt, szDMORootKey, szDMOCategories, GUIDToString(szguid, guidCategory));
- if ((ret = RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &lpedmo->hkey)))
- hr = HRESULT_FROM_WIN32(ret);
+ RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &lpedmo->hkey);
}
lerr:
UINT count = 0;
HRESULT hres = S_OK;
LONG ret;
+ GUID guid;
IEnumDMOImpl *This = impl_from_IEnumDMO(iface);
TRACE("(%p)->(%d %p %p %p)\n", This, cItemsToFetch, pCLSID, Names, pcItemsFetched);
- if (!pCLSID || !Names || !pcItemsFetched)
+ if (!pCLSID || !Names)
return E_POINTER;
+ if (!pcItemsFetched && cItemsToFetch > 1)
+ return E_INVALIDARG;
+
while (count < cItemsToFetch)
{
This->index++;
break;
}
+ if (string_to_guid(szNextKey, &guid) != S_OK)
+ continue;
+
TRACE("found %s\n", debugstr_w(szNextKey));
if (!(This->dwFlags & DMO_ENUMF_INCLUDE_KEYED))
continue;
}
- pInTypes = (DMO_PARTIAL_MEDIATYPE*) szValue;
+ pInTypes = (DMO_PARTIAL_MEDIATYPE *)szValue;
TRACE("read %d intypes for %s:\n", cInTypes, debugstr_w(szKey));
for (i = 0; i < cInTypes; i++) {
for (j = 0; j < cInTypes; j++)
{
if (IsMediaTypeEqual(&pInTypes[j], &This->pInTypes[i]))
- break;
+ break;
}
- if (j >= cInTypes)
+ if (j >= cInTypes)
break;
}
sizeof(szValue)/sizeof(DMO_PARTIAL_MEDIATYPE),
(DMO_PARTIAL_MEDIATYPE*)szValue);
- if (FAILED(hres))
+ if (FAILED(hres))
{
RegCloseKey(hkey);
continue;
}
- pOutTypes = (DMO_PARTIAL_MEDIATYPE*) szValue;
+ pOutTypes = (DMO_PARTIAL_MEDIATYPE *)szValue;
TRACE("read %d outtypes for %s:\n", cOutTypes, debugstr_w(szKey));
for (i = 0; i < cOutTypes; i++) {
for (j = 0; j < cOutTypes; j++)
{
if (IsMediaTypeEqual(&pOutTypes[j], &This->pOutTypes[i]))
- break;
+ break;
}
- if (j >= cOutTypes)
+ if (j >= cOutTypes)
break;
}
}
}
- /* Media object wasn't filtered so add it to return list */
+ /* Media object wasn't filtered so add it to return list */
Names[count] = NULL;
- len = MAX_PATH * sizeof(WCHAR);
+ len = MAX_PATH * sizeof(WCHAR);
ret = RegQueryValueExW(hkey, NULL, NULL, NULL, (LPBYTE)szValue, &len);
if (ERROR_SUCCESS == ret)
- {
+ {
Names[count] = CoTaskMemAlloc((strlenW(szValue) + 1) * sizeof(WCHAR));
- if (Names[count])
+ if (Names[count])
strcpyW(Names[count], szValue);
- }
+ }
wsprintfW(szGuidKey,szToGuidFmt,szNextKey);
CLSIDFromString(szGuidKey, &pCLSID[count]);
TRACE("found match %s %s\n", debugstr_w(szValue), debugstr_w(szNextKey));
RegCloseKey(hkey);
- count++;
+ count++;
}
- *pcItemsFetched = count;
- if (*pcItemsFetched < cItemsToFetch)
+ if (pcItemsFetched) *pcItemsFetched = count;
+ if (count < cItemsToFetch)
hres = S_FALSE;
TRACE("<-- %i found\n",count);