push b79aff4f9e064e6702329573e5ebb8548e254b61
[wine/hacks.git] / dlls / msdmo / dmoreg.c
blob95602348ba5bb226dd017b34399211dfd9f7fd15
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 const IEnumDMOVtbl *lpVtbl;
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 HRESULT read_types(HKEY root, LPCWSTR key, ULONG *supplied, ULONG requested, DMO_PARTIAL_MEDIATYPE* types);
102 static const IEnumDMOVtbl edmovt;
104 static LPWSTR GUIDToString(LPWSTR lpwstr, REFGUID lpcguid)
106 wsprintfW(lpwstr, szGUIDFmt, lpcguid->Data1, lpcguid->Data2,
107 lpcguid->Data3, lpcguid->Data4[0], lpcguid->Data4[1],
108 lpcguid->Data4[2], lpcguid->Data4[3], lpcguid->Data4[4],
109 lpcguid->Data4[5], lpcguid->Data4[6], lpcguid->Data4[7]);
111 return lpwstr;
114 static BOOL IsMediaTypeEqual(const DMO_PARTIAL_MEDIATYPE* mt1, const DMO_PARTIAL_MEDIATYPE* mt2)
117 return (IsEqualCLSID(&mt1->type, &mt2->type) ||
118 IsEqualCLSID(&mt2->type, &GUID_NULL) ||
119 IsEqualCLSID(&mt1->type, &GUID_NULL)) &&
120 (IsEqualCLSID(&mt1->subtype, &mt2->subtype) ||
121 IsEqualCLSID(&mt2->subtype, &GUID_NULL) ||
122 IsEqualCLSID(&mt1->subtype, &GUID_NULL));
125 static HRESULT write_types(HKEY hkey, LPCWSTR name, const DMO_PARTIAL_MEDIATYPE* types, DWORD count)
127 HRESULT hres = S_OK;
128 if (MSDMO_MAJOR_VERSION > 5)
130 hres = RegSetValueExW(hkey, name, 0, REG_BINARY, (const BYTE*) types,
131 count* sizeof(DMO_PARTIAL_MEDIATYPE));
133 else
135 HKEY skey1,skey2,skey3;
136 DWORD index = 0;
137 WCHAR szGuidKey[64];
139 hres = RegCreateKeyExW(hkey, name, 0, NULL, REG_OPTION_NON_VOLATILE,
140 KEY_WRITE, NULL, &skey1, NULL);
141 while (index < count)
143 GUIDToString(szGuidKey,&types[index].type);
144 hres = RegCreateKeyExW(skey1, szGuidKey, 0, NULL,
145 REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &skey2, NULL);
146 GUIDToString(szGuidKey,&types[index].subtype);
147 hres = RegCreateKeyExW(skey2, szGuidKey, 0, NULL,
148 REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &skey3, NULL);
149 RegCloseKey(skey3);
150 RegCloseKey(skey2);
151 index ++;
153 RegCloseKey(skey1);
156 return hres;
159 /***************************************************************
160 * DMORegister (MSDMO.@)
162 * Register a DirectX Media Object.
164 HRESULT WINAPI DMORegister(
165 LPCWSTR szName,
166 REFCLSID clsidDMO,
167 REFGUID guidCategory,
168 DWORD dwFlags,
169 DWORD cInTypes,
170 const DMO_PARTIAL_MEDIATYPE *pInTypes,
171 DWORD cOutTypes,
172 const DMO_PARTIAL_MEDIATYPE *pOutTypes
175 WCHAR szguid[64];
176 HRESULT hres;
177 HKEY hrkey = 0;
178 HKEY hkey = 0;
179 HKEY hckey = 0;
180 HKEY hclskey = 0;
182 TRACE("%s\n", debugstr_w(szName));
184 hres = RegCreateKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0, NULL,
185 REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hrkey, NULL);
186 if (ERROR_SUCCESS != hres)
187 goto lend;
189 /* Create clsidDMO key under MediaObjects */
190 hres = RegCreateKeyExW(hrkey, GUIDToString(szguid, clsidDMO), 0, NULL,
191 REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hkey, NULL);
192 if (ERROR_SUCCESS != hres)
193 goto lend;
195 /* Set default Name value */
196 hres = RegSetValueExW(hkey, NULL, 0, REG_SZ, (const BYTE*) szName,
197 (strlenW(szName) + 1) * sizeof(WCHAR));
199 /* Set InputTypes */
200 hres = write_types(hkey, szDMOInputType, pInTypes, cInTypes);
202 /* Set OutputTypes */
203 hres = write_types(hkey, szDMOOutputType, pOutTypes, cOutTypes);
205 if (dwFlags & DMO_REGISTERF_IS_KEYED)
207 /* Create Keyed key */
208 hres = RegCreateKeyExW(hkey, szDMOKeyed, 0, NULL,
209 REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hckey, NULL);
210 if (ERROR_SUCCESS != hres)
211 goto lend;
212 RegCloseKey(hckey);
215 /* Register the category */
216 hres = RegCreateKeyExW(hrkey, szDMOCategories, 0, NULL,
217 REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hckey, NULL);
218 if (ERROR_SUCCESS != hres)
219 goto lend;
221 RegCloseKey(hkey);
223 hres = RegCreateKeyExW(hckey, GUIDToString(szguid, guidCategory), 0, NULL,
224 REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hkey, NULL);
225 if (ERROR_SUCCESS != hres)
226 goto lend;
227 hres = RegCreateKeyExW(hkey, GUIDToString(szguid, clsidDMO), 0, NULL,
228 REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hclskey, NULL);
229 if (ERROR_SUCCESS != hres)
230 goto lend;
232 lend:
233 if (hkey)
234 RegCloseKey(hkey);
235 if (hckey)
236 RegCloseKey(hckey);
237 if (hclskey)
238 RegCloseKey(hclskey);
239 if (hrkey)
240 RegCloseKey(hrkey);
242 TRACE(" hresult=0x%08x\n", hres);
243 return hres;
247 /***************************************************************
248 * DMOUnregister (MSDMO.@)
250 * Unregister a DirectX Media Object.
252 HRESULT WINAPI DMOUnregister(REFCLSID clsidDMO, REFGUID guidCategory)
254 HRESULT hres;
255 WCHAR szguid[64];
256 HKEY hrkey = 0;
257 HKEY hckey = 0;
259 GUIDToString(szguid, clsidDMO);
261 TRACE("%s %p\n", debugstr_w(szguid), guidCategory);
263 hres = RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0, KEY_WRITE, &hrkey);
264 if (ERROR_SUCCESS != hres)
265 goto lend;
267 hres = RegDeleteKeyW(hrkey, szguid);
268 if (ERROR_SUCCESS != hres)
269 goto lend;
271 hres = RegOpenKeyExW(hrkey, szDMOCategories, 0, KEY_WRITE, &hckey);
272 if (ERROR_SUCCESS != hres)
273 goto lend;
275 hres = RegDeleteKeyW(hckey, szguid);
276 if (ERROR_SUCCESS != hres)
277 goto lend;
279 lend:
280 if (hckey)
281 RegCloseKey(hckey);
282 if (hrkey)
283 RegCloseKey(hrkey);
285 return hres;
289 /***************************************************************
290 * DMOGetName (MSDMO.@)
292 * Get DMP Name from the registry
294 HRESULT WINAPI DMOGetName(REFCLSID clsidDMO, WCHAR szName[80])
296 WCHAR szguid[64];
297 HRESULT hres;
298 HKEY hrkey = 0;
299 HKEY hkey = 0;
300 DWORD count;
302 TRACE("%s\n", debugstr_guid(clsidDMO));
304 hres = RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey,
305 0, KEY_READ, &hrkey);
306 if (ERROR_SUCCESS != hres)
307 goto lend;
309 hres = RegOpenKeyExW(hrkey, GUIDToString(szguid, clsidDMO),
310 0, KEY_READ, &hkey);
311 if (ERROR_SUCCESS != hres)
312 goto lend;
314 count = sizeof(szName);
315 hres = RegQueryValueExW(hkey, NULL, NULL, NULL,
316 (LPBYTE) szName, &count);
318 TRACE(" szName=%s\n", debugstr_w(szName));
319 lend:
320 if (hkey)
321 RegCloseKey(hrkey);
322 if (hkey)
323 RegCloseKey(hkey);
325 return hres;
329 /**************************************************************************
330 * IEnumDMO_Destructor
332 static BOOL IEnumDMO_Destructor(IEnumDMO* iface)
334 IEnumDMOImpl *This = (IEnumDMOImpl *)iface;
336 TRACE("%p\n", This);
338 if (This->hkey)
339 RegCloseKey(This->hkey);
341 HeapFree(GetProcessHeap(), 0, This->pInTypes);
342 HeapFree(GetProcessHeap(), 0, This->pOutTypes);
344 return TRUE;
348 /**************************************************************************
349 * IEnumDMO_Constructor
351 static IEnumDMO * IEnumDMO_Constructor(
352 REFGUID guidCategory,
353 DWORD dwFlags,
354 DWORD cInTypes,
355 const DMO_PARTIAL_MEDIATYPE *pInTypes,
356 DWORD cOutTypes,
357 const DMO_PARTIAL_MEDIATYPE *pOutTypes)
359 UINT size;
360 IEnumDMOImpl* lpedmo;
361 BOOL ret = FALSE;
363 lpedmo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IEnumDMOImpl));
365 if (lpedmo)
367 lpedmo->ref = 1;
368 lpedmo->lpVtbl = &edmovt;
369 lpedmo->index = -1;
370 lpedmo->guidCategory = guidCategory;
371 lpedmo->dwFlags = dwFlags;
373 if (cInTypes > 0)
375 size = cInTypes * sizeof(DMO_PARTIAL_MEDIATYPE);
376 lpedmo->pInTypes = HeapAlloc(GetProcessHeap(), 0, size);
377 if (!lpedmo->pInTypes)
378 goto lerr;
379 memcpy(lpedmo->pInTypes, pInTypes, size);
380 lpedmo->cInTypes = cInTypes;
383 if (cOutTypes > 0)
385 size = cOutTypes * sizeof(DMO_PARTIAL_MEDIATYPE);
386 lpedmo->pOutTypes = HeapAlloc(GetProcessHeap(), 0, size);
387 if (!lpedmo->pOutTypes)
388 goto lerr;
389 memcpy(lpedmo->pOutTypes, pOutTypes, size);
390 lpedmo->cOutTypes = cOutTypes;
393 /* If not filtering by category enum from media objects root */
394 if (IsEqualGUID(guidCategory, &GUID_NULL))
396 if (ERROR_SUCCESS == RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey,
397 0, KEY_READ, &lpedmo->hkey))
398 ret = TRUE;
400 else
402 WCHAR szguid[64];
403 WCHAR szKey[MAX_PATH];
405 wsprintfW(szKey, szCat3Fmt, szDMORootKey, szDMOCategories,
406 GUIDToString(szguid, guidCategory));
407 if (ERROR_SUCCESS == RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey,
408 0, KEY_READ, &lpedmo->hkey))
409 ret = TRUE;
412 lerr:
413 if(!ret)
415 IEnumDMO_Destructor((IEnumDMO*)lpedmo);
416 HeapFree(GetProcessHeap(),0,lpedmo);
417 lpedmo = NULL;
421 TRACE("returning %p\n", lpedmo);
423 return (IEnumDMO*)lpedmo;
427 /******************************************************************************
428 * IEnumDMO_fnAddRef
430 static ULONG WINAPI IEnumDMO_fnAddRef(IEnumDMO * iface)
432 IEnumDMOImpl *This = (IEnumDMOImpl *)iface;
433 return InterlockedIncrement(&This->ref);
437 /**************************************************************************
438 * EnumDMO_QueryInterface
440 static HRESULT WINAPI IEnumDMO_fnQueryInterface(
441 IEnumDMO* iface,
442 REFIID riid,
443 LPVOID *ppvObj)
445 IEnumDMOImpl *This = (IEnumDMOImpl *)iface;
447 *ppvObj = NULL;
449 if(IsEqualIID(riid, &IID_IUnknown))
450 *ppvObj = This;
451 else if(IsEqualIID(riid, &IID_IEnumDMO))
452 *ppvObj = (IEnumDMO*)This;
454 if(*ppvObj)
456 IEnumDMO_fnAddRef((IEnumDMO*)*ppvObj);
457 return S_OK;
460 return E_NOINTERFACE;
464 /******************************************************************************
465 * IEnumDMO_fnRelease
467 static ULONG WINAPI IEnumDMO_fnRelease(IEnumDMO * iface)
469 IEnumDMOImpl *This = (IEnumDMOImpl *)iface;
470 ULONG refCount = InterlockedDecrement(&This->ref);
472 if (!refCount)
474 IEnumDMO_Destructor((IEnumDMO*)This);
475 HeapFree(GetProcessHeap(),0,This);
477 return refCount;
481 /******************************************************************************
482 * IEnumDMO_fnNext
484 static HRESULT WINAPI IEnumDMO_fnNext(
485 IEnumDMO * iface,
486 DWORD cItemsToFetch,
487 CLSID * pCLSID,
488 WCHAR ** Names,
489 DWORD * pcItemsFetched)
491 FILETIME ft;
492 HKEY hkey;
493 WCHAR szNextKey[MAX_PATH];
494 WCHAR szGuidKey[64];
495 WCHAR szKey[MAX_PATH];
496 WCHAR szValue[MAX_PATH];
497 DWORD len;
498 UINT count = 0;
499 HRESULT hres = S_OK;
501 IEnumDMOImpl *This = (IEnumDMOImpl *)iface;
503 TRACE("--> (%p) %d %p %p %p\n", iface, cItemsToFetch, pCLSID, Names, pcItemsFetched);
505 if (!pCLSID || !Names || !pcItemsFetched)
506 return E_POINTER;
508 while (count < cItemsToFetch)
510 This->index++;
512 len = MAX_PATH;
513 hres = RegEnumKeyExW(This->hkey, This->index, szNextKey, &len, NULL, NULL, NULL, &ft);
514 if (hres != ERROR_SUCCESS)
515 break;
517 TRACE("found %s\n", debugstr_w(szNextKey));
519 if (!(This->dwFlags & DMO_ENUMF_INCLUDE_KEYED))
521 wsprintfW(szKey, szCat3Fmt, szDMORootKey, szNextKey, szDMOKeyed);
522 hres = RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &hkey);
523 if (ERROR_SUCCESS == hres)
525 RegCloseKey(hkey);
526 /* Skip Keyed entries */
527 continue;
531 wsprintfW(szKey, szCat2Fmt, szDMORootKey, szNextKey);
532 hres = RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &hkey);
534 if (This->pInTypes)
536 UINT i, j;
537 DWORD cInTypes;
538 DMO_PARTIAL_MEDIATYPE* pInTypes;
540 hres = read_types(hkey, szDMOInputType, &cInTypes,
541 sizeof(szValue)/sizeof(DMO_PARTIAL_MEDIATYPE),
542 (DMO_PARTIAL_MEDIATYPE*)szValue);
544 if (ERROR_SUCCESS != hres)
546 RegCloseKey(hkey);
547 continue;
550 pInTypes = (DMO_PARTIAL_MEDIATYPE*) szValue;
552 for (i = 0; i < This->cInTypes; i++)
554 for (j = 0; j < cInTypes; j++)
556 if (IsMediaTypeEqual(&pInTypes[j], &This->pInTypes[i]))
557 break;
560 if (j >= cInTypes)
561 break;
564 if (i < This->cInTypes)
566 RegCloseKey(hkey);
567 continue;
571 if (This->pOutTypes)
573 UINT i, j;
574 DWORD cOutTypes;
575 DMO_PARTIAL_MEDIATYPE* pOutTypes;
577 hres = read_types(hkey, szDMOOutputType, &cOutTypes,
578 sizeof(szValue)/sizeof(DMO_PARTIAL_MEDIATYPE),
579 (DMO_PARTIAL_MEDIATYPE*)szValue);
581 if (ERROR_SUCCESS != hres)
583 RegCloseKey(hkey);
584 continue;
587 pOutTypes = (DMO_PARTIAL_MEDIATYPE*) szValue;
589 for (i = 0; i < This->cOutTypes; i++)
591 for (j = 0; j < cOutTypes; j++)
593 if (IsMediaTypeEqual(&pOutTypes[j], &This->pOutTypes[i]))
594 break;
597 if (j >= cOutTypes)
598 break;
601 if (i < This->cOutTypes)
603 RegCloseKey(hkey);
604 continue;
608 /* Media object wasn't filtered so add it to return list */
609 Names[count] = NULL;
610 len = MAX_PATH * sizeof(WCHAR);
611 hres = RegQueryValueExW(hkey, NULL, NULL, NULL, (LPBYTE) szValue, &len);
612 if (ERROR_SUCCESS == hres)
614 Names[count] = HeapAlloc(GetProcessHeap(), 0, strlenW(szValue) + 1);
615 if (Names[count])
616 strcmpW(Names[count], szValue);
618 wsprintfW(szGuidKey,szToGuidFmt,szNextKey);
619 CLSIDFromString(szGuidKey, &pCLSID[count]);
621 TRACE("found match %s %s\n", debugstr_w(szValue), debugstr_w(szNextKey));
622 RegCloseKey(hkey);
623 count++;
626 *pcItemsFetched = count;
627 if (*pcItemsFetched < cItemsToFetch)
628 hres = S_FALSE;
630 TRACE("<-- %i found\n",count);
631 return hres;
635 /******************************************************************************
636 * IEnumDMO_fnSkip
638 static HRESULT WINAPI IEnumDMO_fnSkip(IEnumDMO * iface, DWORD cItemsToSkip)
640 IEnumDMOImpl *This = (IEnumDMOImpl *)iface;
642 This->index += cItemsToSkip;
644 return S_OK;
648 /******************************************************************************
649 * IEnumDMO_fnReset
651 static HRESULT WINAPI IEnumDMO_fnReset(IEnumDMO * iface)
653 IEnumDMOImpl *This = (IEnumDMOImpl *)iface;
655 This->index = -1;
657 return S_OK;
661 /******************************************************************************
662 * IEnumDMO_fnClone
664 static HRESULT WINAPI IEnumDMO_fnClone(IEnumDMO * iface, IEnumDMO **ppEnum)
666 IEnumDMOImpl *This = (IEnumDMOImpl *)iface;
668 FIXME("(%p)->() to (%p)->() E_NOTIMPL\n", This, ppEnum);
670 return E_NOTIMPL;
674 /***************************************************************
675 * DMOEnum (MSDMO.@)
677 * Enumerate DirectX Media Objects in the registry.
679 HRESULT WINAPI DMOEnum(
680 REFGUID guidCategory,
681 DWORD dwFlags,
682 DWORD cInTypes,
683 const DMO_PARTIAL_MEDIATYPE *pInTypes,
684 DWORD cOutTypes,
685 const DMO_PARTIAL_MEDIATYPE *pOutTypes,
686 IEnumDMO **ppEnum)
688 HRESULT hres = E_FAIL;
690 TRACE("guidCategory=%p dwFlags=0x%08x cInTypes=%d cOutTypes=%d\n",
691 guidCategory, dwFlags, cInTypes, cOutTypes);
693 *ppEnum = IEnumDMO_Constructor(guidCategory, dwFlags, cInTypes,
694 pInTypes, cOutTypes, pOutTypes);
695 if (*ppEnum)
696 hres = S_OK;
698 return hres;
702 static const IEnumDMOVtbl edmovt =
704 IEnumDMO_fnQueryInterface,
705 IEnumDMO_fnAddRef,
706 IEnumDMO_fnRelease,
707 IEnumDMO_fnNext,
708 IEnumDMO_fnSkip,
709 IEnumDMO_fnReset,
710 IEnumDMO_fnClone,
714 HRESULT read_types(HKEY root, LPCWSTR key, ULONG *supplied, ULONG requested, DMO_PARTIAL_MEDIATYPE* types )
716 HRESULT ret = S_OK;
717 if (MSDMO_MAJOR_VERSION > 5)
719 DWORD len;
720 len = requested * sizeof(DMO_PARTIAL_MEDIATYPE);
721 ret = RegQueryValueExW(root, key, NULL, NULL, (LPBYTE) types, &len);
722 *supplied = len / sizeof(DMO_PARTIAL_MEDIATYPE);
724 else
726 HKEY hkey;
727 WCHAR szGuidKey[64];
729 *supplied = 0;
730 if (ERROR_SUCCESS == RegOpenKeyExW(root, key, 0, KEY_READ, &hkey))
732 int index = 0;
733 WCHAR szNextKey[MAX_PATH];
734 DWORD len;
735 LONG rc = ERROR_SUCCESS;
737 while (rc == ERROR_SUCCESS)
739 len = MAX_PATH * sizeof(WCHAR);
740 rc = RegEnumKeyExW(hkey, index, szNextKey, &len, NULL, NULL, NULL, NULL);
741 if (rc == ERROR_SUCCESS)
743 HKEY subk;
744 int sub_index = 0;
745 LONG rcs = ERROR_SUCCESS;
746 WCHAR szSubKey[MAX_PATH];
748 RegOpenKeyExW(hkey, szNextKey, 0, KEY_READ, &subk);
749 while (rcs == ERROR_SUCCESS)
751 len = MAX_PATH * sizeof(WCHAR);
752 rcs = RegEnumKeyExW(subk, sub_index, szSubKey, &len, NULL, NULL, NULL, NULL);
753 if (rcs == ERROR_SUCCESS)
755 if (*supplied >= requested)
757 /* Bailing */
758 ret = S_FALSE;
759 rc = ERROR_MORE_DATA;
760 rcs = ERROR_MORE_DATA;
761 break;
764 wsprintfW(szGuidKey,szToGuidFmt,szNextKey);
765 CLSIDFromString(szGuidKey, &types[*supplied].type);
766 wsprintfW(szGuidKey,szToGuidFmt,szSubKey);
767 CLSIDFromString(szGuidKey, &types[*supplied].subtype);
768 TRACE("Adding type %s subtype %s at index %i\n",
769 debugstr_guid(&types[*supplied].type),
770 debugstr_guid(&types[*supplied].subtype),
771 *supplied);
772 (*supplied)++;
774 sub_index++;
776 index++;
779 RegCloseKey(hkey);
782 return ret;
785 /***************************************************************
786 * DMOGetTypes (MSDMO.@)
788 HRESULT WINAPI DMOGetTypes(REFCLSID clsidDMO,
789 ULONG ulInputTypesRequested,
790 ULONG* pulInputTypesSupplied,
791 DMO_PARTIAL_MEDIATYPE* pInputTypes,
792 ULONG ulOutputTypesRequested,
793 ULONG* pulOutputTypesSupplied,
794 DMO_PARTIAL_MEDIATYPE* pOutputTypes)
796 HKEY root,hkey;
797 HRESULT ret = S_OK;
798 WCHAR szguid[64];
800 TRACE ("(%s,%u,%p,%p,%u,%p,%p),stub!\n", debugstr_guid(clsidDMO),
801 ulInputTypesRequested, pulInputTypesSupplied, pInputTypes,
802 ulOutputTypesRequested, pulOutputTypesSupplied, pOutputTypes);
804 if (ERROR_SUCCESS != RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0,
805 KEY_READ, &root))
806 return E_FAIL;
808 if (ERROR_SUCCESS != RegOpenKeyExW(root,GUIDToString(szguid,clsidDMO) , 0,
809 KEY_READ, &hkey))
811 RegCloseKey(root);
812 return E_FAIL;
815 if (ulInputTypesRequested > 0)
817 ret = read_types(hkey, szDMOInputType, pulInputTypesSupplied, ulInputTypesRequested, pInputTypes );
819 else
820 *pulInputTypesSupplied = 0;
822 if (ulOutputTypesRequested > 0)
824 HRESULT ret2;
825 ret2 = read_types(hkey, szDMOOutputType, pulOutputTypesSupplied, ulOutputTypesRequested, pOutputTypes );
827 if (ret == S_OK)
828 ret = ret2;
830 else
831 *pulOutputTypesSupplied = 0;
833 return ret;