ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

dmoreg.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2003 Michael Günnewig
00003  * Copyright (C) 2003 CodeWeavers Inc. (Ulrich Czekalla)
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2.1 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public
00016  * License along with this library; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00018  */
00019 
00020 #include <stdarg.h>
00021 
00022 #include "windef.h"
00023 #include "winbase.h"
00024 #include "winuser.h"
00025 #include "winerror.h"
00026 #include "winreg.h"
00027 #include "objbase.h"
00028 #include "wine/unicode.h"
00029 #include "wine/debug.h"
00030 #include "initguid.h"
00031 #include "dmo.h"
00032 
00033 WINE_DEFAULT_DEBUG_CHANNEL(msdmo);
00034 
00035 #define MSDMO_MAJOR_VERSION 6
00036 
00037 static const WCHAR szDMORootKey[] = 
00038 {
00039     'D','i','r','e','c','t','S','h','o','w','\\',
00040     'M','e','d','i','a','O','b','j','e','c','t','s',0
00041 }; 
00042 
00043 static const WCHAR szDMOInputType[] =
00044 {
00045     'I','n','p','u','t','T','y','p','e','s',0
00046 };
00047 
00048 static const WCHAR szDMOOutputType[] =
00049 {
00050     'O','u','t','p','u','t','T','y','p','e','s',0
00051 };
00052 
00053 static const WCHAR szDMOKeyed[] =
00054 {
00055     'K','e','y','e','d',0
00056 };
00057 
00058 static const WCHAR szDMOCategories[] =
00059 {
00060     'C','a','t','e','g','o','r','i','e','s',0
00061 };
00062 
00063 static const WCHAR szGUIDFmt[] =
00064 {
00065     '%','0','8','X','-','%','0','4','X','-','%','0','4','X','-','%','0',
00066     '2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','%','0','2',
00067     'X','%','0','2','X','%','0','2','X','%','0','2','X',0
00068 };
00069 
00070 static const WCHAR szCat3Fmt[] =
00071 {
00072     '%','s','\\','%','s','\\','%','s',0
00073 };
00074 
00075 static const WCHAR szCat2Fmt[] =
00076 {
00077     '%','s','\\','%','s',0
00078 };
00079 
00080 static const WCHAR szToGuidFmt[] =
00081 {
00082     '{','%','s','}',0
00083 };
00084 
00085 
00086 typedef struct
00087 {
00088     const IEnumDMOVtbl         *lpVtbl;
00089     LONG            ref;
00090     DWORD           index;
00091     const GUID*                 guidCategory;
00092     DWORD                       dwFlags;
00093     DWORD                       cInTypes;
00094     DMO_PARTIAL_MEDIATYPE       *pInTypes;
00095     DWORD                       cOutTypes;
00096     DMO_PARTIAL_MEDIATYPE       *pOutTypes;
00097     HKEY                        hkey;
00098 } IEnumDMOImpl;
00099 
00100 static HRESULT read_types(HKEY root, LPCWSTR key, ULONG *supplied, ULONG requested, DMO_PARTIAL_MEDIATYPE* types);
00101 
00102 static const IEnumDMOVtbl edmovt;
00103 
00104 static LPWSTR GUIDToString(LPWSTR lpwstr, REFGUID lpcguid)
00105 {
00106     wsprintfW(lpwstr, szGUIDFmt, lpcguid->Data1, lpcguid->Data2,
00107         lpcguid->Data3, lpcguid->Data4[0], lpcguid->Data4[1],
00108         lpcguid->Data4[2], lpcguid->Data4[3], lpcguid->Data4[4],
00109         lpcguid->Data4[5], lpcguid->Data4[6], lpcguid->Data4[7]);
00110 
00111     return lpwstr;
00112 }
00113 
00114 static BOOL IsMediaTypeEqual(const DMO_PARTIAL_MEDIATYPE* mt1, const DMO_PARTIAL_MEDIATYPE* mt2)
00115 {
00116 
00117     return (IsEqualCLSID(&mt1->type, &mt2->type) ||
00118             IsEqualCLSID(&mt2->type, &GUID_NULL) ||
00119             IsEqualCLSID(&mt1->type, &GUID_NULL)) &&
00120             (IsEqualCLSID(&mt1->subtype, &mt2->subtype) ||
00121             IsEqualCLSID(&mt2->subtype, &GUID_NULL) ||
00122             IsEqualCLSID(&mt1->subtype, &GUID_NULL));
00123 }
00124 
00125 static HRESULT write_types(HKEY hkey, LPCWSTR name, const DMO_PARTIAL_MEDIATYPE* types, DWORD count)
00126 {
00127     HRESULT hres = S_OK;
00128     if (MSDMO_MAJOR_VERSION > 5)
00129     {
00130         hres = RegSetValueExW(hkey, name, 0, REG_BINARY, (const BYTE*) types,
00131                           count* sizeof(DMO_PARTIAL_MEDIATYPE));
00132     }
00133     else
00134     {
00135         HKEY skey1,skey2,skey3;
00136         DWORD index = 0;
00137         WCHAR szGuidKey[64];
00138 
00139         hres = RegCreateKeyExW(hkey, name, 0, NULL, REG_OPTION_NON_VOLATILE,
00140                                KEY_WRITE, NULL, &skey1, NULL);
00141         while (index < count)
00142         {
00143             GUIDToString(szGuidKey,&types[index].type);
00144             hres = RegCreateKeyExW(skey1, szGuidKey, 0, NULL,
00145                         REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &skey2, NULL);
00146             GUIDToString(szGuidKey,&types[index].subtype);
00147             hres = RegCreateKeyExW(skey2, szGuidKey, 0, NULL,
00148                         REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &skey3, NULL);
00149             RegCloseKey(skey3);
00150             RegCloseKey(skey2);
00151             index ++;
00152         }
00153         RegCloseKey(skey1);
00154     }
00155 
00156     return hres;
00157 }
00158 
00159 /***************************************************************
00160  * DMORegister (MSDMO.@)
00161  *
00162  * Register a DirectX Media Object.
00163  */
00164 HRESULT WINAPI DMORegister(
00165    LPCWSTR szName,
00166    REFCLSID clsidDMO,
00167    REFGUID guidCategory,
00168    DWORD dwFlags,
00169    DWORD cInTypes,
00170    const DMO_PARTIAL_MEDIATYPE *pInTypes,
00171    DWORD cOutTypes,
00172    const DMO_PARTIAL_MEDIATYPE *pOutTypes
00173 )
00174 {
00175     WCHAR szguid[64];
00176     HRESULT hres;
00177     HKEY hrkey = 0;
00178     HKEY hkey = 0;
00179     HKEY hckey = 0;
00180     HKEY hclskey = 0;
00181 
00182     TRACE("%s\n", debugstr_w(szName));
00183 
00184     hres = RegCreateKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0, NULL,
00185         REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hrkey, NULL);
00186     if (ERROR_SUCCESS != hres)
00187         goto lend;
00188 
00189     /* Create clsidDMO key under MediaObjects */ 
00190     hres = RegCreateKeyExW(hrkey, GUIDToString(szguid, clsidDMO), 0, NULL,
00191         REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hkey, NULL);
00192     if (ERROR_SUCCESS != hres)
00193         goto lend;
00194 
00195     /* Set default Name value */
00196     hres = RegSetValueExW(hkey, NULL, 0, REG_SZ, (const BYTE*) szName, 
00197         (strlenW(szName) + 1) * sizeof(WCHAR));
00198 
00199     /* Set InputTypes */
00200     hres = write_types(hkey, szDMOInputType, pInTypes, cInTypes);
00201 
00202     /* Set OutputTypes */
00203     hres = write_types(hkey, szDMOOutputType, pOutTypes, cOutTypes);
00204 
00205     if (dwFlags & DMO_REGISTERF_IS_KEYED)
00206     {
00207         /* Create Keyed key */ 
00208         hres = RegCreateKeyExW(hkey, szDMOKeyed, 0, NULL,
00209             REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hckey, NULL);
00210         if (ERROR_SUCCESS != hres)
00211             goto lend;
00212         RegCloseKey(hckey);
00213     }
00214 
00215     /* Register the category */
00216     hres = RegCreateKeyExW(hrkey, szDMOCategories, 0, NULL,
00217             REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hckey, NULL);
00218     if (ERROR_SUCCESS != hres)
00219         goto lend;
00220 
00221     RegCloseKey(hkey);
00222 
00223     hres = RegCreateKeyExW(hckey, GUIDToString(szguid, guidCategory), 0, NULL,
00224             REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hkey, NULL);
00225     if (ERROR_SUCCESS != hres)
00226         goto lend;
00227     hres = RegCreateKeyExW(hkey, GUIDToString(szguid, clsidDMO), 0, NULL,
00228         REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hclskey, NULL);
00229     if (ERROR_SUCCESS != hres)
00230         goto lend;
00231 
00232 lend:
00233     if (hkey)
00234         RegCloseKey(hkey);
00235     if (hckey)
00236         RegCloseKey(hckey);
00237     if (hclskey)
00238         RegCloseKey(hclskey);
00239     if (hrkey)
00240         RegCloseKey(hrkey);
00241 
00242     TRACE(" hresult=0x%08x\n", hres);
00243     return hres;
00244 }
00245 
00246 
00247 /***************************************************************
00248  * DMOUnregister (MSDMO.@)
00249  *
00250  * Unregister a DirectX Media Object.
00251  */
00252 HRESULT WINAPI DMOUnregister(REFCLSID clsidDMO, REFGUID guidCategory)
00253 {
00254     HRESULT hres;
00255     WCHAR szguid[64];
00256     HKEY hrkey = 0;
00257     HKEY hckey = 0;
00258 
00259     GUIDToString(szguid, clsidDMO);
00260 
00261     TRACE("%s %p\n", debugstr_w(szguid), guidCategory);
00262 
00263     hres = RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0, KEY_WRITE, &hrkey);
00264     if (ERROR_SUCCESS != hres)
00265         goto lend;
00266 
00267     hres = RegDeleteKeyW(hrkey, szguid);
00268     if (ERROR_SUCCESS != hres)
00269         goto lend;
00270 
00271     hres = RegOpenKeyExW(hrkey, szDMOCategories, 0, KEY_WRITE, &hckey);
00272     if (ERROR_SUCCESS != hres)
00273         goto lend;
00274 
00275     hres = RegDeleteKeyW(hckey, szguid);
00276     if (ERROR_SUCCESS != hres)
00277         goto lend;
00278 
00279 lend:
00280     if (hckey)
00281         RegCloseKey(hckey);
00282     if (hrkey)
00283         RegCloseKey(hrkey);
00284 
00285     return hres;
00286 }
00287 
00288 
00289 /***************************************************************
00290  * DMOGetName (MSDMO.@)
00291  *
00292  * Get DMP Name from the registry
00293  */
00294 HRESULT WINAPI DMOGetName(REFCLSID clsidDMO, WCHAR szName[])
00295 {
00296     WCHAR szguid[64];
00297     HRESULT hres;
00298     HKEY hrkey = 0;
00299     HKEY hkey = 0;
00300     static const INT max_name_len = 80;
00301     DWORD count;
00302 
00303     TRACE("%s\n", debugstr_guid(clsidDMO));
00304 
00305     hres = RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 
00306         0, KEY_READ, &hrkey);
00307     if (ERROR_SUCCESS != hres)
00308         goto lend;
00309 
00310     hres = RegOpenKeyExW(hrkey, GUIDToString(szguid, clsidDMO),
00311         0, KEY_READ, &hkey);
00312     if (ERROR_SUCCESS != hres)
00313         goto lend;
00314 
00315     count = max_name_len * sizeof(WCHAR);
00316     hres = RegQueryValueExW(hkey, NULL, NULL, NULL, 
00317         (LPBYTE) szName, &count); 
00318 
00319     TRACE(" szName=%s\n", debugstr_w(szName));
00320 lend:
00321     if (hkey)
00322         RegCloseKey(hrkey);
00323     if (hkey)
00324         RegCloseKey(hkey);
00325 
00326     return hres;
00327 }
00328 
00329 
00330 /**************************************************************************
00331 *   IEnumDMO_Destructor
00332 */
00333 static BOOL IEnumDMO_Destructor(IEnumDMO* iface)
00334 {
00335     IEnumDMOImpl *This = (IEnumDMOImpl *)iface;
00336 
00337     TRACE("%p\n", This);
00338 
00339     if (This->hkey)
00340         RegCloseKey(This->hkey);
00341 
00342     HeapFree(GetProcessHeap(), 0, This->pInTypes);
00343     HeapFree(GetProcessHeap(), 0, This->pOutTypes);
00344 
00345     return TRUE;
00346 }
00347 
00348 
00349 /**************************************************************************
00350  *  IEnumDMO_Constructor
00351  */
00352 static IEnumDMO * IEnumDMO_Constructor(
00353     REFGUID guidCategory,
00354     DWORD dwFlags,
00355     DWORD cInTypes,
00356     const DMO_PARTIAL_MEDIATYPE *pInTypes,
00357     DWORD cOutTypes,
00358     const DMO_PARTIAL_MEDIATYPE *pOutTypes)
00359 {
00360     UINT size;
00361     IEnumDMOImpl* lpedmo;
00362     BOOL ret = FALSE;
00363 
00364     lpedmo = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IEnumDMOImpl));
00365 
00366     if (lpedmo)
00367     {
00368         lpedmo->ref = 1;
00369         lpedmo->lpVtbl = &edmovt;
00370         lpedmo->index = -1;
00371     lpedmo->guidCategory = guidCategory;
00372     lpedmo->dwFlags = dwFlags;
00373 
00374         if (cInTypes > 0)
00375         {
00376             size = cInTypes * sizeof(DMO_PARTIAL_MEDIATYPE);
00377             lpedmo->pInTypes = HeapAlloc(GetProcessHeap(), 0, size);
00378             if (!lpedmo->pInTypes)
00379                 goto lerr;
00380             memcpy(lpedmo->pInTypes, pInTypes, size);
00381             lpedmo->cInTypes = cInTypes;
00382         }
00383 
00384         if (cOutTypes > 0)
00385         {
00386             size = cOutTypes * sizeof(DMO_PARTIAL_MEDIATYPE);
00387             lpedmo->pOutTypes = HeapAlloc(GetProcessHeap(), 0, size);
00388             if (!lpedmo->pOutTypes)
00389                 goto lerr;
00390             memcpy(lpedmo->pOutTypes, pOutTypes, size);
00391             lpedmo->cOutTypes = cOutTypes;
00392         }
00393 
00394         /* If not filtering by category enum from media objects root */
00395         if (IsEqualGUID(guidCategory, &GUID_NULL))
00396         {
00397             if (ERROR_SUCCESS == RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 
00398                 0, KEY_READ, &lpedmo->hkey))
00399                 ret = TRUE;
00400         }
00401         else
00402         {
00403             WCHAR szguid[64];
00404             WCHAR szKey[MAX_PATH];
00405 
00406             wsprintfW(szKey, szCat3Fmt, szDMORootKey, szDMOCategories, 
00407                 GUIDToString(szguid, guidCategory));
00408             if (ERROR_SUCCESS == RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey, 
00409                 0, KEY_READ, &lpedmo->hkey))
00410                 ret = TRUE;
00411         }
00412 
00413 lerr:
00414         if(!ret)
00415         {
00416             IEnumDMO_Destructor((IEnumDMO*)lpedmo);
00417             HeapFree(GetProcessHeap(),0,lpedmo);
00418             lpedmo = NULL;
00419         }
00420     }
00421 
00422     TRACE("returning %p\n", lpedmo);
00423 
00424     return (IEnumDMO*)lpedmo;
00425 }
00426 
00427 
00428 /******************************************************************************
00429  * IEnumDMO_fnAddRef
00430  */
00431 static ULONG WINAPI IEnumDMO_fnAddRef(IEnumDMO * iface)
00432 {
00433     IEnumDMOImpl *This = (IEnumDMOImpl *)iface;
00434     return InterlockedIncrement(&This->ref);
00435 }
00436 
00437 
00438 /**************************************************************************
00439  *  EnumDMO_QueryInterface
00440  */
00441 static HRESULT WINAPI IEnumDMO_fnQueryInterface(
00442     IEnumDMO* iface,
00443     REFIID riid,
00444     LPVOID *ppvObj)
00445 {
00446     IEnumDMOImpl *This = (IEnumDMOImpl *)iface;
00447 
00448     *ppvObj = NULL;
00449 
00450     if(IsEqualIID(riid, &IID_IUnknown))
00451         *ppvObj = This;
00452     else if(IsEqualIID(riid, &IID_IEnumDMO))
00453         *ppvObj = This;
00454 
00455     if(*ppvObj)
00456     {
00457         IEnumDMO_fnAddRef(*ppvObj);
00458         return S_OK;
00459     }
00460 
00461     return E_NOINTERFACE;
00462 }
00463 
00464 
00465 /******************************************************************************
00466  * IEnumDMO_fnRelease
00467  */
00468 static ULONG WINAPI IEnumDMO_fnRelease(IEnumDMO * iface)
00469 {
00470     IEnumDMOImpl *This = (IEnumDMOImpl *)iface;
00471     ULONG refCount = InterlockedDecrement(&This->ref);
00472 
00473     if (!refCount)
00474     {
00475         IEnumDMO_Destructor((IEnumDMO*)This);
00476         HeapFree(GetProcessHeap(),0,This);
00477     }
00478     return refCount;
00479 }
00480 
00481 
00482 /******************************************************************************
00483  * IEnumDMO_fnNext
00484  */
00485 static HRESULT WINAPI IEnumDMO_fnNext(
00486     IEnumDMO * iface, 
00487     DWORD cItemsToFetch,
00488     CLSID * pCLSID,
00489     WCHAR ** Names,
00490     DWORD * pcItemsFetched)
00491 {
00492     FILETIME ft;
00493     HKEY hkey;
00494     WCHAR szNextKey[MAX_PATH];
00495     WCHAR szGuidKey[64];
00496     WCHAR szKey[MAX_PATH];
00497     WCHAR szValue[MAX_PATH];
00498     DWORD len;
00499     UINT count = 0;
00500     HRESULT hres = S_OK;
00501 
00502     IEnumDMOImpl *This = (IEnumDMOImpl *)iface;
00503 
00504     TRACE("--> (%p) %d %p %p %p\n", iface, cItemsToFetch, pCLSID, Names, pcItemsFetched);
00505 
00506     if (!pCLSID || !Names || !pcItemsFetched)
00507         return E_POINTER;
00508 
00509     while (count < cItemsToFetch)
00510     {
00511         This->index++;
00512 
00513         len = MAX_PATH;
00514         hres = RegEnumKeyExW(This->hkey, This->index, szNextKey, &len, NULL, NULL, NULL, &ft);
00515         if (hres != ERROR_SUCCESS)
00516             break;
00517 
00518         TRACE("found %s\n", debugstr_w(szNextKey));
00519 
00520         if (!(This->dwFlags & DMO_ENUMF_INCLUDE_KEYED))
00521         {
00522             wsprintfW(szKey, szCat3Fmt, szDMORootKey, szNextKey, szDMOKeyed);
00523             hres = RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &hkey);
00524             if (ERROR_SUCCESS == hres)
00525             {
00526                 RegCloseKey(hkey);
00527                 /* Skip Keyed entries */
00528                 continue;
00529             }
00530         }
00531 
00532         wsprintfW(szKey, szCat2Fmt, szDMORootKey, szNextKey);
00533         hres = RegOpenKeyExW(HKEY_CLASSES_ROOT, szKey, 0, KEY_READ, &hkey);
00534 
00535         if (This->pInTypes)
00536         {
00537             UINT i, j;
00538             DWORD cInTypes;
00539             DMO_PARTIAL_MEDIATYPE* pInTypes;
00540 
00541             hres = read_types(hkey, szDMOInputType, &cInTypes,
00542                     sizeof(szValue)/sizeof(DMO_PARTIAL_MEDIATYPE),
00543                     (DMO_PARTIAL_MEDIATYPE*)szValue);
00544 
00545             if (ERROR_SUCCESS != hres)
00546             {
00547                 RegCloseKey(hkey);
00548                 continue;
00549             }
00550 
00551         pInTypes = (DMO_PARTIAL_MEDIATYPE*) szValue;
00552 
00553             for (i = 0; i < This->cInTypes; i++)
00554             {
00555                 for (j = 0; j < cInTypes; j++) 
00556                 {
00557                     if (IsMediaTypeEqual(&pInTypes[j], &This->pInTypes[i]))
00558                 break;
00559                 }
00560 
00561         if (j >= cInTypes)
00562                     break;
00563             }
00564 
00565             if (i < This->cInTypes)
00566             {
00567                 RegCloseKey(hkey);
00568                 continue;
00569             }
00570         }
00571 
00572         if (This->pOutTypes)
00573         {
00574             UINT i, j;
00575             DWORD cOutTypes;
00576             DMO_PARTIAL_MEDIATYPE* pOutTypes;
00577 
00578             hres = read_types(hkey, szDMOOutputType, &cOutTypes,
00579                     sizeof(szValue)/sizeof(DMO_PARTIAL_MEDIATYPE),
00580                     (DMO_PARTIAL_MEDIATYPE*)szValue);
00581 
00582         if (ERROR_SUCCESS != hres)
00583             {
00584                 RegCloseKey(hkey);
00585                 continue;
00586             }
00587 
00588         pOutTypes = (DMO_PARTIAL_MEDIATYPE*) szValue;
00589 
00590             for (i = 0; i < This->cOutTypes; i++)
00591             {
00592                 for (j = 0; j < cOutTypes; j++) 
00593                 {
00594                     if (IsMediaTypeEqual(&pOutTypes[j], &This->pOutTypes[i]))
00595                 break;
00596                 }
00597 
00598         if (j >= cOutTypes)
00599                     break;
00600             }
00601 
00602             if (i < This->cOutTypes)
00603             {
00604                 RegCloseKey(hkey);
00605                 continue;
00606             }
00607         }
00608 
00609     /* Media object wasn't filtered so add it to return list */
00610         Names[count] = NULL;
00611     len = MAX_PATH * sizeof(WCHAR);
00612         hres = RegQueryValueExW(hkey, NULL, NULL, NULL, (LPBYTE) szValue, &len); 
00613         if (ERROR_SUCCESS == hres)
00614     {
00615             Names[count] = HeapAlloc(GetProcessHeap(), 0, strlenW(szValue) + 1);
00616         if (Names[count])
00617                 strcmpW(Names[count], szValue);
00618     }
00619         wsprintfW(szGuidKey,szToGuidFmt,szNextKey);
00620         CLSIDFromString(szGuidKey, &pCLSID[count]);
00621 
00622         TRACE("found match %s %s\n", debugstr_w(szValue), debugstr_w(szNextKey));
00623         RegCloseKey(hkey);
00624     count++;
00625     }
00626 
00627     *pcItemsFetched = count;
00628     if (*pcItemsFetched < cItemsToFetch)
00629         hres = S_FALSE;
00630 
00631     TRACE("<-- %i found\n",count);
00632     return hres;
00633 }
00634  
00635 
00636 /******************************************************************************
00637  * IEnumDMO_fnSkip
00638  */
00639 static HRESULT WINAPI IEnumDMO_fnSkip(IEnumDMO * iface, DWORD cItemsToSkip)
00640 {
00641     IEnumDMOImpl *This = (IEnumDMOImpl *)iface;
00642 
00643     This->index += cItemsToSkip;
00644 
00645     return S_OK;
00646 }
00647 
00648 
00649 /******************************************************************************
00650  * IEnumDMO_fnReset
00651  */
00652 static HRESULT WINAPI IEnumDMO_fnReset(IEnumDMO * iface)
00653 {
00654     IEnumDMOImpl *This = (IEnumDMOImpl *)iface;
00655 
00656     This->index = -1;
00657 
00658     return S_OK;
00659 }
00660  
00661 
00662 /******************************************************************************
00663  * IEnumDMO_fnClone
00664  */
00665 static HRESULT WINAPI IEnumDMO_fnClone(IEnumDMO * iface, IEnumDMO **ppEnum)
00666 {
00667     IEnumDMOImpl *This = (IEnumDMOImpl *)iface;
00668 
00669     FIXME("(%p)->() to (%p)->() E_NOTIMPL\n", This, ppEnum);
00670 
00671   return E_NOTIMPL;
00672 }
00673 
00674 
00675 /***************************************************************
00676  * DMOEnum (MSDMO.@)
00677  *
00678  * Enumerate DirectX Media Objects in the registry.
00679  */
00680 HRESULT WINAPI DMOEnum(
00681     REFGUID guidCategory,
00682     DWORD dwFlags,
00683     DWORD cInTypes,
00684     const DMO_PARTIAL_MEDIATYPE *pInTypes,
00685     DWORD cOutTypes,
00686     const DMO_PARTIAL_MEDIATYPE *pOutTypes,
00687     IEnumDMO **ppEnum)
00688 {
00689     HRESULT hres = E_FAIL;
00690 
00691     TRACE("guidCategory=%p dwFlags=0x%08x cInTypes=%d cOutTypes=%d\n",
00692         guidCategory, dwFlags, cInTypes, cOutTypes);
00693 
00694     *ppEnum = IEnumDMO_Constructor(guidCategory, dwFlags, cInTypes,
00695         pInTypes, cOutTypes, pOutTypes);
00696     if (*ppEnum)
00697         hres = S_OK;
00698 
00699     return hres;
00700 }
00701 
00702 
00703 static const IEnumDMOVtbl edmovt =
00704 {
00705     IEnumDMO_fnQueryInterface,
00706     IEnumDMO_fnAddRef,
00707     IEnumDMO_fnRelease,
00708     IEnumDMO_fnNext,
00709     IEnumDMO_fnSkip,
00710     IEnumDMO_fnReset,
00711     IEnumDMO_fnClone,
00712 };
00713 
00714 
00715 HRESULT read_types(HKEY root, LPCWSTR key, ULONG *supplied, ULONG requested, DMO_PARTIAL_MEDIATYPE* types )
00716 {
00717     HRESULT ret = S_OK;
00718     if (MSDMO_MAJOR_VERSION > 5)
00719     {
00720         DWORD len;
00721         len = requested * sizeof(DMO_PARTIAL_MEDIATYPE);
00722         ret = RegQueryValueExW(root, key, NULL, NULL, (LPBYTE) types, &len);
00723         *supplied = len / sizeof(DMO_PARTIAL_MEDIATYPE);
00724     }
00725     else
00726     {
00727         HKEY hkey;
00728         WCHAR szGuidKey[64];
00729 
00730         *supplied = 0;
00731         if (ERROR_SUCCESS == RegOpenKeyExW(root, key, 0, KEY_READ, &hkey))
00732         {
00733           int index = 0;
00734           WCHAR szNextKey[MAX_PATH];
00735           DWORD len;
00736           LONG rc = ERROR_SUCCESS;
00737 
00738           while (rc == ERROR_SUCCESS)
00739           {
00740             len = MAX_PATH;
00741             rc = RegEnumKeyExW(hkey, index, szNextKey, &len, NULL, NULL, NULL, NULL);
00742             if (rc == ERROR_SUCCESS)
00743             {
00744               HKEY subk;
00745               int sub_index = 0;
00746               LONG rcs = ERROR_SUCCESS;
00747               WCHAR szSubKey[MAX_PATH];
00748 
00749               RegOpenKeyExW(hkey, szNextKey, 0, KEY_READ, &subk);
00750               while (rcs == ERROR_SUCCESS)
00751               {
00752                 len = MAX_PATH;
00753                 rcs = RegEnumKeyExW(subk, sub_index, szSubKey, &len, NULL, NULL, NULL, NULL);
00754                 if (rcs == ERROR_SUCCESS)
00755                 {
00756                   if (*supplied >= requested)
00757                   {
00758                     /* Bailing */
00759                     ret = S_FALSE;
00760                     rc = ERROR_MORE_DATA;
00761                     rcs = ERROR_MORE_DATA;
00762                     break;
00763                   }
00764 
00765                   wsprintfW(szGuidKey,szToGuidFmt,szNextKey);
00766                   CLSIDFromString(szGuidKey, &types[*supplied].type);
00767                   wsprintfW(szGuidKey,szToGuidFmt,szSubKey);
00768                   CLSIDFromString(szGuidKey, &types[*supplied].subtype);
00769                   TRACE("Adding type %s subtype %s at index %i\n",
00770                     debugstr_guid(&types[*supplied].type),
00771                     debugstr_guid(&types[*supplied].subtype),
00772                     *supplied);
00773                   (*supplied)++;
00774                 }
00775                 sub_index++;
00776               }
00777               index++;
00778             }
00779           }
00780           RegCloseKey(hkey);
00781         }
00782     }
00783     return ret;
00784 }
00785 
00786 /***************************************************************
00787  * DMOGetTypes (MSDMO.@)
00788  */
00789 HRESULT WINAPI DMOGetTypes(REFCLSID clsidDMO,
00790                ULONG ulInputTypesRequested,
00791                ULONG* pulInputTypesSupplied,
00792                DMO_PARTIAL_MEDIATYPE* pInputTypes,
00793                ULONG ulOutputTypesRequested,
00794                ULONG* pulOutputTypesSupplied,
00795                DMO_PARTIAL_MEDIATYPE* pOutputTypes)
00796 {
00797   HKEY root,hkey;
00798   HRESULT ret = S_OK;
00799   WCHAR szguid[64];
00800 
00801   TRACE ("(%s,%u,%p,%p,%u,%p,%p),stub!\n", debugstr_guid(clsidDMO),
00802         ulInputTypesRequested, pulInputTypesSupplied, pInputTypes,
00803         ulOutputTypesRequested, pulOutputTypesSupplied, pOutputTypes);
00804 
00805   if (ERROR_SUCCESS != RegOpenKeyExW(HKEY_CLASSES_ROOT, szDMORootKey, 0,
00806                                      KEY_READ, &root))
00807     return E_FAIL;
00808 
00809   if (ERROR_SUCCESS != RegOpenKeyExW(root,GUIDToString(szguid,clsidDMO) , 0,
00810                                      KEY_READ, &hkey))
00811   {
00812     RegCloseKey(root);
00813     return E_FAIL;
00814   }
00815 
00816   if (ulInputTypesRequested > 0)
00817   {
00818     ret = read_types(hkey, szDMOInputType, pulInputTypesSupplied, ulInputTypesRequested, pInputTypes );
00819   }
00820   else
00821     *pulInputTypesSupplied = 0;
00822 
00823   if (ulOutputTypesRequested > 0)
00824   {
00825     HRESULT ret2;
00826     ret2 = read_types(hkey, szDMOOutputType, pulOutputTypesSupplied, ulOutputTypesRequested, pOutputTypes );
00827 
00828     if (ret == S_OK)
00829         ret = ret2;
00830   }
00831   else
00832     *pulOutputTypesSupplied = 0;
00833 
00834   return ret;
00835 }

Generated on Sun May 27 2012 04:21:53 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.