po: Update French translation.
[wine.git] / dlls / msdmo / dmoreg.c
blobfb1caa115929ef1a1c89dc034dde04ff29209345
1 /*
2 * Copyright (C) 2003 Michael Günnewig
3 * Copyright (C) 2003 CodeWeavers Inc. (Ulrich Czekalla)
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <stdarg.h>
22 #include "windef.h"
23 #include "winbase.h"
24 #include "winuser.h"
25 #include "winerror.h"
26 #include "winreg.h"
27 #include "objbase.h"
28 #include "wine/unicode.h"
29 #include "wine/debug.h"
30 #include "initguid.h"
31 #include "dmo.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(msdmo);
35 #define MSDMO_MAJOR_VERSION 6
37 static const WCHAR szDMORootKey[] =
39 'D','i','r','e','c','t','S','h','o','w','\\',
40 'M','e','d','i','a','O','b','j','e','c','t','s',0
41 };
43 static const WCHAR szDMOInputType[] =
45 'I','n','p','u','t','T','y','p','e','s',0
48 static const WCHAR szDMOOutputType[] =
50 'O','u','t','p','u','t','T','y','p','e','s',0
53 static const WCHAR szDMOKeyed[] =
55 'K','e','y','e','d',0
58 static const WCHAR szDMOCategories[] =
60 'C','a','t','e','g','o','r','i','e','s',0
63 static const WCHAR szGUIDFmt[] =
65 '%','0','8','X','-','%','0','4','X','-','%','0','4','X','-','%','0',
66 '2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','%','0','2',
67 'X','%','0','2','X','%','0','2','X','%','0','2','X',0
70 static const WCHAR szCat3Fmt[] =
72 '%','s','\\','%','s','\\','%','s',0
75 static const WCHAR szCat2Fmt[] =
77 '%','s','\\','%','s',0
80 static const WCHAR szToGuidFmt[] =
82 '{','%','s','}',0
86 typedef struct
88 IEnumDMO IEnumDMO_iface;
89 LONG ref;
90 DWORD index;
91 const GUID* guidCategory;
92 DWORD dwFlags;
93 DWORD cInTypes;
94 DMO_PARTIAL_MEDIATYPE *pInTypes;
95 DWORD cOutTypes;
96 DMO_PARTIAL_MEDIATYPE *pOutTypes;
97 HKEY hkey;
98 } IEnumDMOImpl;
100 static inline IEnumDMOImpl *impl_from_IEnumDMO(IEnumDMO *iface)
102 return CONTAINING_RECORD(iface, IEnumDMOImpl, IEnumDMO_iface);
105 static HRESULT read_types(HKEY root, LPCWSTR key, ULONG *supplied, ULONG requested, DMO_PARTIAL_MEDIATYPE* types);
107 static const IEnumDMOVtbl edmovt;
109 static LPWSTR GUIDToString(LPWSTR lpwstr, REFGUID lpcguid)
111 wsprintfW(lpwstr, szGUIDFmt, lpcguid->Data1, lpcguid->Data2,
112 lpcguid->Data3, lpcguid->Data4[0], lpcguid->Data4[1],
113 lpcguid->Data4[2], lpcguid->Data4[3], lpcguid->Data4[4],
114 lpcguid->Data4[5], lpcguid->Data4[6], lpcguid->Data4[7]);
116 return lpwstr;
119 static BOOL IsMediaTypeEqual(const DMO_PARTIAL_MEDIATYPE* mt1, const DMO_PARTIAL_MEDIATYPE* mt2)
122 return (IsEqualCLSID(&mt1->type, &mt2->type) ||
123 IsEqualCLSID(&mt2->type, &GUID_NULL) ||
124 IsEqualCLSID(&mt1->type, &GUID_NULL)) &&
125 (IsEqualCLSID(&mt1->subtype, &mt2->subtype) ||
126 IsEqualCLSID(&mt2->subtype, &GUID_NULL) ||
127 IsEqualCLSID(&mt1->subtype, &GUID_NULL));
130 static HRESULT write_types(HKEY hkey, LPCWSTR name, const DMO_PARTIAL_MEDIATYPE* types, DWORD count)
132 HRESULT hres = S_OK;
133 if (MSDMO_MAJOR_VERSION > 5)
135 hres = RegSetValueExW(hkey, name, 0, REG_BINARY, (const BYTE*) types,
136 count* sizeof(DMO_PARTIAL_MEDIATYPE));
138 else
140 HKEY skey1,skey2,skey3;
141 DWORD index = 0;
142 WCHAR szGuidKey[64];
144 hres = RegCreateKeyExW(hkey, name, 0, NULL, REG_OPTION_NON_VOLATILE,
145 KEY_WRITE, NULL, &skey1, NULL);
146 while (index < count)
148 GUIDToString(szGuidKey,&types[index].type);
149 hres = RegCreateKeyExW(skey1, szGuidKey, 0, NULL,
150 REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &skey2, NULL);
151 GUIDToString(szGuidKey,&types[index].subtype);
152 hres = RegCreateKeyExW(skey2, szGuidKey, 0, NULL,
153 REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &skey3, NULL);
154 RegCloseKey(skey3);
155 RegCloseKey(skey2);
156 index ++;
158 RegCloseKey(skey1);
161 return hres;
164 /***************************************************************
165 * DMORegister (MSDMO.@)
167 * Register a DirectX Media Object.
169 HRESULT WINAPI DMORegister(
170 LPCWSTR szName,
171 REFCLSID clsidDMO,
172 REFGUID guidCategory,
173 DWORD dwFlags,
174 DWORD cInTypes,
175 const DMO_PARTIAL_MEDIATYPE *pInTypes,
176 DWORD cOutTypes,
177 const DMO_PARTIAL_MEDIATYPE *pOutTypes
180 WCHAR szguid[64];
181 HRESULT hres;
182 HKEY hrkey = 0;
183 HKEY hkey = 0;
184 HKEY hckey = 0;
185 HKEY hclskey = 0;
187 TRACE("%s\n", debugstr_w(szName));
189 hres = RegCreateKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0, NULL,
190 REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hrkey, NULL);
191 if (ERROR_SUCCESS != hres)
192 goto lend;
194 /* Create clsidDMO key under MediaObjects */
195 hres = RegCreateKeyExW(hrkey, GUIDToString(szguid, clsidDMO), 0, NULL,
196 REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hkey, NULL);
197 if (ERROR_SUCCESS != hres)
198 goto lend;
200 /* Set default Name value */
201 hres = RegSetValueExW(hkey, NULL, 0, REG_SZ, (const BYTE*) szName,
202 (strlenW(szName) + 1) * sizeof(WCHAR));
204 /* Set InputTypes */
205 hres = write_types(hkey, szDMOInputType, pInTypes, cInTypes);
207 /* Set OutputTypes */
208 hres = write_types(hkey, szDMOOutputType, pOutTypes, cOutTypes);
210 if (dwFlags & DMO_REGISTERF_IS_KEYED)
212 /* Create Keyed key */
213 hres = RegCreateKeyExW(hkey, szDMOKeyed, 0, NULL,
214 REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hckey, NULL);
215 if (ERROR_SUCCESS != hres)
216 goto lend;
217 RegCloseKey(hckey);
220 /* Register the category */
221 hres = RegCreateKeyExW(hrkey, szDMOCategories, 0, NULL,
222 REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hckey, NULL);
223 if (ERROR_SUCCESS != hres)
224 goto lend;
226 RegCloseKey(hkey);
228 hres = RegCreateKeyExW(hckey, GUIDToString(szguid, guidCategory), 0, NULL,
229 REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hkey, NULL);
230 if (ERROR_SUCCESS != hres)
231 goto lend;
232 hres = RegCreateKeyExW(hkey, GUIDToString(szguid, clsidDMO), 0, NULL,
233 REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hclskey, NULL);
234 if (ERROR_SUCCESS != hres)
235 goto lend;
237 lend:
238 if (hkey)
239 RegCloseKey(hkey);
240 if (hckey)
241 RegCloseKey(hckey);
242 if (hclskey)
243 RegCloseKey(hclskey);
244 if (hrkey)
245 RegCloseKey(hrkey);
247 TRACE(" hresult=0x%08x\n", hres);
248 return hres;
252 /***************************************************************
253 * DMOUnregister (MSDMO.@)
255 * Unregister a DirectX Media Object.
257 HRESULT WINAPI DMOUnregister(REFCLSID clsidDMO, REFGUID guidCategory)
259 HRESULT hres;
260 WCHAR szguid[64];
261 HKEY hrkey = 0;
262 HKEY hckey = 0;
264 GUIDToString(szguid, clsidDMO);
266 TRACE("%s %p\n", debugstr_w(szguid), guidCategory);
268 hres = RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0, KEY_WRITE, &hrkey);
269 if (ERROR_SUCCESS != hres)
270 goto lend;
272 hres = RegDeleteKeyW(hrkey, szguid);
273 if (ERROR_SUCCESS != hres)
274 goto lend;
276 hres = RegOpenKeyExW(hrkey, szDMOCategories, 0, KEY_WRITE, &hckey);
277 if (ERROR_SUCCESS != hres)
278 goto lend;
280 hres = RegDeleteKeyW(hckey, szguid);
281 if (ERROR_SUCCESS != hres)
282 goto lend;
284 lend:
285 if (hckey)
286 RegCloseKey(hckey);
287 if (hrkey)
288 RegCloseKey(hrkey);
290 return hres;
294 /***************************************************************
295 * DMOGetName (MSDMO.@)
297 * Get DMP Name from the registry
299 HRESULT WINAPI DMOGetName(REFCLSID clsidDMO, WCHAR szName[])
301 WCHAR szguid[64];
302 HRESULT hres;
303 HKEY hrkey = 0;
304 HKEY hkey = 0;
305 static const INT max_name_len = 80;
306 DWORD count;
308 TRACE("%s\n", debugstr_guid(clsidDMO));
310 hres = RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey,
311 0, KEY_READ, &hrkey);
312 if (ERROR_SUCCESS != hres)
313 goto lend;
315 hres = RegOpenKeyExW(hrkey, GUIDToString(szguid, clsidDMO),
316 0, KEY_READ, &hkey);
317 if (ERROR_SUCCESS != hres)
318 goto lend;
320 count = max_name_len * sizeof(WCHAR);
321 hres = RegQueryValueExW(hkey, NULL, NULL, NULL,
322 (LPBYTE) szName, &count);
324 TRACE(" szName=%s\n", debugstr_w(szName));
325 lend:
326 if (hkey)
327 RegCloseKey(hrkey);
328 if (hkey)
329 RegCloseKey(hkey);
331 return hres;
335 /**************************************************************************
336 * IEnumDMOImpl_Destructor
338 static BOOL IEnumDMOImpl_Destructor(IEnumDMOImpl* This)
340 TRACE("%p\n", This);
342 if (This->hkey)
343 RegCloseKey(This->hkey);
345 HeapFree(GetProcessHeap(), 0, This->pInTypes);
346 HeapFree(GetProcessHeap(), 0, This->pOutTypes);
348 return TRUE;
352 /**************************************************************************
353 * IEnumDMO_Constructor
355 static IEnumDMO * IEnumDMO_Constructor(
356 REFGUID guidCategory,
357 DWORD dwFlags,
358 DWORD cInTypes,
359 const DMO_PARTIAL_MEDIATYPE *pInTypes,
360 DWORD cOutTypes,
361 const DMO_PARTIAL_MEDIATYPE *pOutTypes)
363 UINT size;
364 IEnumDMOImpl* lpedmo;
365 BOOL ret = FALSE;
367 lpedmo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IEnumDMOImpl));
369 if (lpedmo)
371 lpedmo->ref = 1;
372 lpedmo->IEnumDMO_iface.lpVtbl = &edmovt;
373 lpedmo->index = -1;
374 lpedmo->guidCategory = guidCategory;
375 lpedmo->dwFlags = dwFlags;
377 if (cInTypes > 0)
379 size = cInTypes * sizeof(DMO_PARTIAL_MEDIATYPE);
380 lpedmo->pInTypes = HeapAlloc(GetProcessHeap(), 0, size);
381 if (!lpedmo->pInTypes)
382 goto lerr;
383 memcpy(lpedmo->pInTypes, pInTypes, size);
384 lpedmo->cInTypes = cInTypes;
387 if (cOutTypes > 0)
389 size = cOutTypes * sizeof(DMO_PARTIAL_MEDIATYPE);
390 lpedmo->pOutTypes = HeapAlloc(GetProcessHeap(), 0, size);
391 if (!lpedmo->pOutTypes)
392 goto lerr;
393 memcpy(lpedmo->pOutTypes, pOutTypes, size);
394 lpedmo->cOutTypes = cOutTypes;
397 /* If not filtering by category enum from media objects root */
398 if (IsEqualGUID(guidCategory, &GUID_NULL))
400 if (ERROR_SUCCESS == RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey,
401 0, KEY_READ, &lpedmo->hkey))
402 ret = TRUE;
404 else
406 WCHAR szguid[64];
407 WCHAR szKey[MAX_PATH];
409 wsprintfW(szKey, szCat3Fmt, szDMORootKey, szDMOCategories,
410 GUIDToString(szguid, guidCategory));
411 if (ERROR_SUCCESS == RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey,
412 0, KEY_READ, &lpedmo->hkey))
413 ret = TRUE;
416 lerr:
417 if(!ret)
419 IEnumDMOImpl_Destructor(lpedmo);
420 HeapFree(GetProcessHeap(),0,lpedmo);
421 lpedmo = NULL;
425 TRACE("returning %p\n", lpedmo);
427 return (IEnumDMO*)lpedmo;
431 /******************************************************************************
432 * IEnumDMO_fnAddRef
434 static ULONG WINAPI IEnumDMO_fnAddRef(IEnumDMO * iface)
436 IEnumDMOImpl *This = impl_from_IEnumDMO(iface);
437 return InterlockedIncrement(&This->ref);
441 /**************************************************************************
442 * EnumDMO_QueryInterface
444 static HRESULT WINAPI IEnumDMO_fnQueryInterface(
445 IEnumDMO* iface,
446 REFIID riid,
447 LPVOID *ppvObj)
449 IEnumDMOImpl *This = impl_from_IEnumDMO(iface);
451 *ppvObj = NULL;
453 if(IsEqualIID(riid, &IID_IUnknown))
454 *ppvObj = This;
455 else if(IsEqualIID(riid, &IID_IEnumDMO))
456 *ppvObj = This;
458 if(*ppvObj)
460 IEnumDMO_fnAddRef(*ppvObj);
461 return S_OK;
464 return E_NOINTERFACE;
468 /******************************************************************************
469 * IEnumDMO_fnRelease
471 static ULONG WINAPI IEnumDMO_fnRelease(IEnumDMO * iface)
473 IEnumDMOImpl *This = impl_from_IEnumDMO(iface);
474 ULONG refCount = InterlockedDecrement(&This->ref);
476 if (!refCount)
478 IEnumDMOImpl_Destructor(This);
479 HeapFree(GetProcessHeap(),0,This);
481 return refCount;
485 /******************************************************************************
486 * IEnumDMO_fnNext
488 static HRESULT WINAPI IEnumDMO_fnNext(
489 IEnumDMO * iface,
490 DWORD cItemsToFetch,
491 CLSID * pCLSID,
492 WCHAR ** Names,
493 DWORD * pcItemsFetched)
495 FILETIME ft;
496 HKEY hkey;
497 WCHAR szNextKey[MAX_PATH];
498 WCHAR szGuidKey[64];
499 WCHAR szKey[MAX_PATH];
500 WCHAR szValue[MAX_PATH];
501 DWORD len;
502 UINT count = 0;
503 HRESULT hres = S_OK;
505 IEnumDMOImpl *This = impl_from_IEnumDMO(iface);
507 TRACE("--> (%p) %d %p %p %p\n", iface, cItemsToFetch, pCLSID, Names, pcItemsFetched);
509 if (!pCLSID || !Names || !pcItemsFetched)
510 return E_POINTER;
512 while (count < cItemsToFetch)
514 This->index++;
516 len = MAX_PATH;
517 hres = RegEnumKeyExW(This->hkey, This->index, szNextKey, &len, NULL, NULL, NULL, &ft);
518 if (hres != ERROR_SUCCESS)
519 break;
521 TRACE("found %s\n", debugstr_w(szNextKey));
523 if (!(This->dwFlags & DMO_ENUMF_INCLUDE_KEYED))
525 wsprintfW(szKey, szCat3Fmt, szDMORootKey, szNextKey, szDMOKeyed);
526 hres = RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &hkey);
527 if (ERROR_SUCCESS == hres)
529 RegCloseKey(hkey);
530 /* Skip Keyed entries */
531 continue;
535 wsprintfW(szKey, szCat2Fmt, szDMORootKey, szNextKey);
536 hres = RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &hkey);
538 if (This->pInTypes)
540 UINT i, j;
541 DWORD cInTypes;
542 DMO_PARTIAL_MEDIATYPE* pInTypes;
544 hres = read_types(hkey, szDMOInputType, &cInTypes,
545 sizeof(szValue)/sizeof(DMO_PARTIAL_MEDIATYPE),
546 (DMO_PARTIAL_MEDIATYPE*)szValue);
548 if (ERROR_SUCCESS != hres)
550 RegCloseKey(hkey);
551 continue;
554 pInTypes = (DMO_PARTIAL_MEDIATYPE*) szValue;
556 for (i = 0; i < This->cInTypes; i++)
558 for (j = 0; j < cInTypes; j++)
560 if (IsMediaTypeEqual(&pInTypes[j], &This->pInTypes[i]))
561 break;
564 if (j >= cInTypes)
565 break;
568 if (i < This->cInTypes)
570 RegCloseKey(hkey);
571 continue;
575 if (This->pOutTypes)
577 UINT i, j;
578 DWORD cOutTypes;
579 DMO_PARTIAL_MEDIATYPE* pOutTypes;
581 hres = read_types(hkey, szDMOOutputType, &cOutTypes,
582 sizeof(szValue)/sizeof(DMO_PARTIAL_MEDIATYPE),
583 (DMO_PARTIAL_MEDIATYPE*)szValue);
585 if (ERROR_SUCCESS != hres)
587 RegCloseKey(hkey);
588 continue;
591 pOutTypes = (DMO_PARTIAL_MEDIATYPE*) szValue;
593 for (i = 0; i < This->cOutTypes; i++)
595 for (j = 0; j < cOutTypes; j++)
597 if (IsMediaTypeEqual(&pOutTypes[j], &This->pOutTypes[i]))
598 break;
601 if (j >= cOutTypes)
602 break;
605 if (i < This->cOutTypes)
607 RegCloseKey(hkey);
608 continue;
612 /* Media object wasn't filtered so add it to return list */
613 Names[count] = NULL;
614 len = MAX_PATH * sizeof(WCHAR);
615 hres = RegQueryValueExW(hkey, NULL, NULL, NULL, (LPBYTE) szValue, &len);
616 if (ERROR_SUCCESS == hres)
618 Names[count] = HeapAlloc(GetProcessHeap(), 0, strlenW(szValue) + 1);
619 if (Names[count])
620 strcmpW(Names[count], szValue);
622 wsprintfW(szGuidKey,szToGuidFmt,szNextKey);
623 CLSIDFromString(szGuidKey, &pCLSID[count]);
625 TRACE("found match %s %s\n", debugstr_w(szValue), debugstr_w(szNextKey));
626 RegCloseKey(hkey);
627 count++;
630 *pcItemsFetched = count;
631 if (*pcItemsFetched < cItemsToFetch)
632 hres = S_FALSE;
634 TRACE("<-- %i found\n",count);
635 return hres;
639 /******************************************************************************
640 * IEnumDMO_fnSkip
642 static HRESULT WINAPI IEnumDMO_fnSkip(IEnumDMO * iface, DWORD cItemsToSkip)
644 IEnumDMOImpl *This = impl_from_IEnumDMO(iface);
646 This->index += cItemsToSkip;
648 return S_OK;
652 /******************************************************************************
653 * IEnumDMO_fnReset
655 static HRESULT WINAPI IEnumDMO_fnReset(IEnumDMO * iface)
657 IEnumDMOImpl *This = impl_from_IEnumDMO(iface);
659 This->index = -1;
661 return S_OK;
665 /******************************************************************************
666 * IEnumDMO_fnClone
668 static HRESULT WINAPI IEnumDMO_fnClone(IEnumDMO * iface, IEnumDMO **ppEnum)
670 IEnumDMOImpl *This = impl_from_IEnumDMO(iface);
672 FIXME("(%p)->() to (%p)->() E_NOTIMPL\n", This, ppEnum);
674 return E_NOTIMPL;
678 /***************************************************************
679 * DMOEnum (MSDMO.@)
681 * Enumerate DirectX Media Objects in the registry.
683 HRESULT WINAPI DMOEnum(
684 REFGUID guidCategory,
685 DWORD dwFlags,
686 DWORD cInTypes,
687 const DMO_PARTIAL_MEDIATYPE *pInTypes,
688 DWORD cOutTypes,
689 const DMO_PARTIAL_MEDIATYPE *pOutTypes,
690 IEnumDMO **ppEnum)
692 HRESULT hres = E_FAIL;
694 TRACE("guidCategory=%p dwFlags=0x%08x cInTypes=%d cOutTypes=%d\n",
695 guidCategory, dwFlags, cInTypes, cOutTypes);
697 *ppEnum = IEnumDMO_Constructor(guidCategory, dwFlags, cInTypes,
698 pInTypes, cOutTypes, pOutTypes);
699 if (*ppEnum)
700 hres = S_OK;
702 return hres;
706 static const IEnumDMOVtbl edmovt =
708 IEnumDMO_fnQueryInterface,
709 IEnumDMO_fnAddRef,
710 IEnumDMO_fnRelease,
711 IEnumDMO_fnNext,
712 IEnumDMO_fnSkip,
713 IEnumDMO_fnReset,
714 IEnumDMO_fnClone,
718 HRESULT read_types(HKEY root, LPCWSTR key, ULONG *supplied, ULONG requested, DMO_PARTIAL_MEDIATYPE* types )
720 HRESULT ret = S_OK;
721 if (MSDMO_MAJOR_VERSION > 5)
723 DWORD len;
724 len = requested * sizeof(DMO_PARTIAL_MEDIATYPE);
725 ret = RegQueryValueExW(root, key, NULL, NULL, (LPBYTE) types, &len);
726 *supplied = len / sizeof(DMO_PARTIAL_MEDIATYPE);
728 else
730 HKEY hkey;
731 WCHAR szGuidKey[64];
733 *supplied = 0;
734 if (ERROR_SUCCESS == RegOpenKeyExW(root, key, 0, KEY_READ, &hkey))
736 int index = 0;
737 WCHAR szNextKey[MAX_PATH];
738 DWORD len;
739 LONG rc = ERROR_SUCCESS;
741 while (rc == ERROR_SUCCESS)
743 len = MAX_PATH;
744 rc = RegEnumKeyExW(hkey, index, szNextKey, &len, NULL, NULL, NULL, NULL);
745 if (rc == ERROR_SUCCESS)
747 HKEY subk;
748 int sub_index = 0;
749 LONG rcs = ERROR_SUCCESS;
750 WCHAR szSubKey[MAX_PATH];
752 RegOpenKeyExW(hkey, szNextKey, 0, KEY_READ, &subk);
753 while (rcs == ERROR_SUCCESS)
755 len = MAX_PATH;
756 rcs = RegEnumKeyExW(subk, sub_index, szSubKey, &len, NULL, NULL, NULL, NULL);
757 if (rcs == ERROR_SUCCESS)
759 if (*supplied >= requested)
761 /* Bailing */
762 ret = S_FALSE;
763 rc = ERROR_MORE_DATA;
764 rcs = ERROR_MORE_DATA;
765 break;
768 wsprintfW(szGuidKey,szToGuidFmt,szNextKey);
769 CLSIDFromString(szGuidKey, &types[*supplied].type);
770 wsprintfW(szGuidKey,szToGuidFmt,szSubKey);
771 CLSIDFromString(szGuidKey, &types[*supplied].subtype);
772 TRACE("Adding type %s subtype %s at index %i\n",
773 debugstr_guid(&types[*supplied].type),
774 debugstr_guid(&types[*supplied].subtype),
775 *supplied);
776 (*supplied)++;
778 sub_index++;
780 index++;
783 RegCloseKey(hkey);
786 return ret;
789 /***************************************************************
790 * DMOGetTypes (MSDMO.@)
792 HRESULT WINAPI DMOGetTypes(REFCLSID clsidDMO,
793 ULONG ulInputTypesRequested,
794 ULONG* pulInputTypesSupplied,
795 DMO_PARTIAL_MEDIATYPE* pInputTypes,
796 ULONG ulOutputTypesRequested,
797 ULONG* pulOutputTypesSupplied,
798 DMO_PARTIAL_MEDIATYPE* pOutputTypes)
800 HKEY root,hkey;
801 HRESULT ret = S_OK;
802 WCHAR szguid[64];
804 TRACE ("(%s,%u,%p,%p,%u,%p,%p)\n", debugstr_guid(clsidDMO), ulInputTypesRequested,
805 pulInputTypesSupplied, pInputTypes, ulOutputTypesRequested, pulOutputTypesSupplied,
806 pOutputTypes);
808 if (ERROR_SUCCESS != RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0,
809 KEY_READ, &root))
810 return E_FAIL;
812 if (ERROR_SUCCESS != RegOpenKeyExW(root,GUIDToString(szguid,clsidDMO) , 0,
813 KEY_READ, &hkey))
815 RegCloseKey(root);
816 return E_FAIL;
819 if (ulInputTypesRequested > 0)
821 ret = read_types(hkey, szDMOInputType, pulInputTypesSupplied, ulInputTypesRequested, pInputTypes );
823 else
824 *pulInputTypesSupplied = 0;
826 if (ulOutputTypesRequested > 0)
828 HRESULT ret2;
829 ret2 = read_types(hkey, szDMOOutputType, pulOutputTypesSupplied, ulOutputTypesRequested, pOutputTypes );
831 if (ret == S_OK)
832 ret = ret2;
834 else
835 *pulOutputTypesSupplied = 0;
837 return ret;