ReactOS  0.4.14-dev-41-g31d7680
mediacatenum.c
Go to the documentation of this file.
1 /*
2  * IEnumMoniker implementation for DEVENUM.dll
3  *
4  * Copyright (C) 2002 Robert Shearman
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  *
20  * NOTES ON THIS FILE:
21  * - Implements IEnumMoniker interface which enumerates through moniker
22  * objects created from HKEY_CLASSES/CLSID/{DEVICE_CLSID}/Instance
23  */
24 
25 #include "devenum_private.h"
26 #include "oleauto.h"
27 #include "ocidl.h"
28 
29 #include "wine/debug.h"
30 
32 
33 typedef struct
34 {
36  CLSID class;
43 
44 typedef struct
45 {
51 
52 
54 {
55  return CONTAINING_RECORD(iface, RegPropBagImpl, IPropertyBag_iface);
56 }
57 
59  LPPROPERTYBAG iface,
60  REFIID riid,
61  LPVOID *ppvObj)
62 {
64 
65  TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppvObj);
66 
67  if (This == NULL || ppvObj == NULL) return E_POINTER;
68 
69  if (IsEqualGUID(riid, &IID_IUnknown) ||
71  {
72  *ppvObj = iface;
73  IPropertyBag_AddRef(iface);
74  return S_OK;
75  }
76 
77  FIXME("- no interface IID: %s\n", debugstr_guid(riid));
78  return E_NOINTERFACE;
79 }
80 
81 /**********************************************************************
82  * DEVENUM_IPropertyBag_AddRef (also IUnknown)
83  */
84 static ULONG WINAPI DEVENUM_IPropertyBag_AddRef(LPPROPERTYBAG iface)
85 {
87 
88  TRACE("(%p)->() AddRef from %d\n", iface, This->ref);
89 
90  return InterlockedIncrement(&This->ref);
91 }
92 
93 /**********************************************************************
94  * DEVENUM_IPropertyBag_Release (also IUnknown)
95  */
96 static ULONG WINAPI DEVENUM_IPropertyBag_Release(LPPROPERTYBAG iface)
97 {
99  ULONG ref;
100 
101  TRACE("(%p)->() ReleaseThis->ref from %d\n", iface, This->ref);
102 
103  ref = InterlockedDecrement(&This->ref);
104  if (ref == 0) {
107  }
108  return ref;
109 }
110 
112  LPPROPERTYBAG iface,
113  LPCOLESTR pszPropName,
114  VARIANT* pVar,
115  IErrorLog* pErrorLog)
116 {
117  LPVOID pData = NULL;
118  DWORD received;
119  DWORD type = 0;
121  HRESULT res = S_OK;
122  LONG reswin32 = ERROR_SUCCESS;
123  HKEY hkey;
124 
125  TRACE("(%p)->(%s, %p, %p)\n", This, debugstr_w(pszPropName), pVar, pErrorLog);
126 
127  if (!pszPropName || !pVar)
128  return E_POINTER;
129 
130  if (This->type == DEVICE_FILTER)
131  reswin32 = RegOpenKeyW(HKEY_CLASSES_ROOT, This->path, &hkey);
132  else if (This->type == DEVICE_CODEC)
133  reswin32 = RegOpenKeyW(HKEY_CURRENT_USER, This->path, &hkey);
134  res = HRESULT_FROM_WIN32(reswin32);
135 
136  if (SUCCEEDED(res))
137  {
138  reswin32 = RegQueryValueExW(hkey, pszPropName, NULL, NULL, NULL, &received);
139  res = HRESULT_FROM_WIN32(reswin32);
140  }
141 
142  if (SUCCEEDED(res))
143  {
145 
146  /* work around a GCC bug that occurs here unless we use the reswin32 variable as well */
147  reswin32 = RegQueryValueExW(hkey, pszPropName, NULL, &type, pData, &received);
148  res = HRESULT_FROM_WIN32(reswin32);
149  }
150 
151  if (SUCCEEDED(res))
152  {
153  res = E_INVALIDARG; /* assume we cannot coerce into right type */
154 
155  TRACE("Read %d bytes (%s)\n", received, type == REG_SZ ? debugstr_w(pData) : "binary data");
156 
157  switch (type)
158  {
159  case REG_SZ:
160  switch (V_VT(pVar))
161  {
162  case VT_LPWSTR:
163  V_BSTR(pVar) = CoTaskMemAlloc(received);
164  memcpy(V_BSTR(pVar), pData, received);
165  res = S_OK;
166  break;
167  case VT_EMPTY:
168  V_VT(pVar) = VT_BSTR;
169  /* fall through */
170  case VT_BSTR:
171  V_BSTR(pVar) = SysAllocStringLen(pData, received/sizeof(WCHAR) - 1);
172  res = S_OK;
173  break;
174  }
175  break;
176  case REG_DWORD:
177  TRACE("REG_DWORD: %x\n", *(DWORD *)pData);
178  switch (V_VT(pVar))
179  {
180  case VT_EMPTY:
181  V_VT(pVar) = VT_I4;
182  /* fall through */
183  case VT_I4:
184  case VT_UI4:
185  V_I4(pVar) = *(DWORD *)pData;
186  res = S_OK;
187  break;
188  }
189  break;
190  case REG_BINARY:
191  {
192  SAFEARRAYBOUND bound;
193  void * pArrayElements;
194  bound.lLbound = 0;
195  bound.cElements = received;
196  TRACE("REG_BINARY: len = %d\n", received);
197  switch (V_VT(pVar))
198  {
199  case VT_EMPTY:
200  V_VT(pVar) = VT_ARRAY | VT_UI1;
201  /* fall through */
202  case VT_ARRAY | VT_UI1:
203  if (!(V_ARRAY(pVar) = SafeArrayCreate(VT_UI1, 1, &bound)))
204  res = E_OUTOFMEMORY;
205  else
206  res = S_OK;
207  break;
208  }
209 
210  if (res == E_INVALIDARG)
211  break;
212 
213  res = SafeArrayAccessData(V_ARRAY(pVar), &pArrayElements);
214  if (FAILED(res))
215  break;
216 
217  CopyMemory(pArrayElements, pData, received);
219  break;
220  }
221  }
222  if (res == E_INVALIDARG)
223  FIXME("Variant type %x not supported for regtype %x\n", V_VT(pVar), type);
224  }
225 
227 
228  RegCloseKey(hkey);
229 
230  TRACE("<- %x\n", res);
231  return res;
232 }
233 
235  LPPROPERTYBAG iface,
236  LPCOLESTR pszPropName,
237  VARIANT* pVar)
238 {
240  LPVOID lpData = NULL;
241  DWORD cbData = 0;
242  DWORD dwType = 0;
243  HRESULT res = S_OK;
244  LONG lres = ERROR_SUCCESS;
245  HKEY hkey;
246 
247  TRACE("(%p)->(%s, %p)\n", This, debugstr_w(pszPropName), pVar);
248 
249  switch (V_VT(pVar))
250  {
251  case VT_BSTR:
252  case VT_LPWSTR:
253  TRACE("writing %s\n", debugstr_w(V_BSTR(pVar)));
254  lpData = V_BSTR(pVar);
255  dwType = REG_SZ;
256  cbData = (lstrlenW(V_BSTR(pVar)) + 1) * sizeof(WCHAR);
257  break;
258  case VT_I4:
259  case VT_UI4:
260  TRACE("writing %u\n", V_UI4(pVar));
261  lpData = &V_UI4(pVar);
262  dwType = REG_DWORD;
263  cbData = sizeof(DWORD);
264  break;
265  case VT_ARRAY | VT_UI1:
266  {
267  LONG lUbound = 0;
268  LONG lLbound = 0;
269  dwType = REG_BINARY;
270  res = SafeArrayGetLBound(V_ARRAY(pVar), 1, &lLbound);
271  res = SafeArrayGetUBound(V_ARRAY(pVar), 1, &lUbound);
272  cbData = (lUbound - lLbound + 1) /* * sizeof(BYTE)*/;
273  TRACE("cbData: %d\n", cbData);
274  res = SafeArrayAccessData(V_ARRAY(pVar), &lpData);
275  break;
276  }
277  default:
278  FIXME("Variant type %d not handled\n", V_VT(pVar));
279  return E_FAIL;
280  }
281 
282  if (This->type == DEVICE_FILTER)
283  lres = RegCreateKeyW(HKEY_CLASSES_ROOT, This->path, &hkey);
284  else if (This->type == DEVICE_CODEC)
285  lres = RegCreateKeyW(HKEY_CURRENT_USER, This->path, &hkey);
286  res = HRESULT_FROM_WIN32(lres);
287 
288  if (SUCCEEDED(res))
289  {
290  lres = RegSetValueExW(hkey, pszPropName, 0, dwType, lpData, cbData);
291  res = HRESULT_FROM_WIN32(lres);
292  RegCloseKey(hkey);
293  }
294 
295  if (V_VT(pVar) & VT_ARRAY)
297 
298  return res;
299 }
300 
301 static const IPropertyBagVtbl IPropertyBag_Vtbl =
302 {
308 };
309 
311 {
313  if (!rpb)
314  return E_OUTOFMEMORY;
315  rpb->IPropertyBag_iface.lpVtbl = &IPropertyBag_Vtbl;
316  rpb->ref = 1;
317  rpb->type = mon->type;
318 
319  if (rpb->type == DEVICE_FILTER)
320  strcpyW(rpb->path, clsidW);
321  else if (rpb->type == DEVICE_CODEC)
323  if (mon->has_class)
324  {
325  StringFromGUID2(&mon->class, rpb->path + strlenW(rpb->path), CHARS_IN_GUID);
326  if (rpb->type == DEVICE_FILTER)
327  strcatW(rpb->path, instanceW);
328  strcatW(rpb->path, backslashW);
329  }
330  strcatW(rpb->path, mon->name);
331 
332  *ppBag = &rpb->IPropertyBag_iface;
334  return S_OK;
335 }
336 
337 
339 {
340  return CONTAINING_RECORD(iface, MediaCatMoniker, IMoniker_iface);
341 }
342 
344  void **ppv)
345 {
346  TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
347 
348  if (!ppv)
349  return E_POINTER;
350 
351  if (IsEqualGUID(riid, &IID_IUnknown) ||
354  IsEqualGUID(riid, &IID_IMoniker))
355  {
356  *ppv = iface;
357  IMoniker_AddRef(iface);
358  return S_OK;
359  }
360 
361  FIXME("- no interface IID: %s\n", debugstr_guid(riid));
362  *ppv = NULL;
363  return E_NOINTERFACE;
364 }
365 
367 {
370 
371  TRACE("(%p) ref=%d\n", This, ref);
372 
373  return ref;
374 }
375 
377 {
380 
381  TRACE("(%p) ref=%d\n", This, ref);
382 
383  if (ref == 0) {
384  CoTaskMemFree(This->name);
387  }
388  return ref;
389 }
390 
392 {
394 
395  TRACE("(%p)->(%p)\n", This, pClassID);
396 
397  if (pClassID == NULL)
398  return E_INVALIDARG;
399 
400  *pClassID = CLSID_CDeviceMoniker;
401 
402  return S_OK;
403 }
404 
406 {
407  FIXME("(%p)->(): stub\n", iface);
408 
409  return S_FALSE;
410 }
411 
413 {
414  FIXME("(%p)->(%p): stub\n", iface, pStm);
415 
416  return E_NOTIMPL;
417 }
418 
420 {
421  FIXME("(%p)->(%p, %s): stub\n", iface, pStm, fClearDirty ? "true" : "false");
422 
423  return STG_E_CANTSAVE;
424 }
425 
427 {
428  FIXME("(%p)->(%p): stub\n", iface, pcbSize);
429 
430  ZeroMemory(pcbSize, sizeof(*pcbSize));
431 
432  return S_OK;
433 }
434 
436  IMoniker *pmkToLeft, REFIID riidResult, void **ppvResult)
437 {
439  IUnknown * pObj = NULL;
440  IPropertyBag * pProp = NULL;
441  CLSID clsID;
442  VARIANT var;
443  HRESULT res = E_FAIL;
444 
445  TRACE("(%p)->(%p, %p, %s, %p)\n", This, pbc, pmkToLeft, debugstr_guid(riidResult), ppvResult);
446 
447  if (!ppvResult)
448  return E_POINTER;
449 
450  VariantInit(&var);
451  *ppvResult = NULL;
452 
453  if(pmkToLeft==NULL)
454  {
455  /* first activation of this class */
456  LPVOID pvptr;
457  res=IMoniker_BindToStorage(iface, NULL, NULL, &IID_IPropertyBag, &pvptr);
458  pProp = pvptr;
459  if (SUCCEEDED(res))
460  {
461  V_VT(&var) = VT_LPWSTR;
462  res = IPropertyBag_Read(pProp, clsid_keyname, &var, NULL);
463  }
464  if (SUCCEEDED(res))
465  {
466  res = CLSIDFromString(V_BSTR(&var), &clsID);
467  CoTaskMemFree(V_BSTR(&var));
468  }
469  if (SUCCEEDED(res))
470  {
471  res=CoCreateInstance(&clsID,NULL,CLSCTX_ALL,&IID_IUnknown,&pvptr);
472  pObj = pvptr;
473  }
474  }
475 
476  if (pObj!=NULL)
477  {
478  /* get the requested interface from the loaded class */
479  res = S_OK;
480  if (pProp) {
481  HRESULT res2;
482  LPVOID ppv = NULL;
483  res2 = IUnknown_QueryInterface(pObj, &IID_IPersistPropertyBag, &ppv);
484  if (SUCCEEDED(res2)) {
485  res = IPersistPropertyBag_Load((IPersistPropertyBag *) ppv, pProp, NULL);
486  IPersistPropertyBag_Release((IPersistPropertyBag *) ppv);
487  }
488  }
489  if (SUCCEEDED(res))
490  res= IUnknown_QueryInterface(pObj,riidResult,ppvResult);
491  IUnknown_Release(pObj);
492  }
493 
494  if (pProp)
495  {
496  IPropertyBag_Release(pProp);
497  }
498 
499  TRACE("<- 0x%x\n", res);
500 
501  return res;
502 }
503 
505  IMoniker *pmkToLeft, REFIID riid, void **ppvObj)
506 {
508 
509  TRACE("(%p)->(%p, %p, %s, %p)\n", This, pbc, pmkToLeft, debugstr_guid(riid), ppvObj);
510 
511  *ppvObj = NULL;
512 
513  if (pmkToLeft)
514  return MK_E_NOSTORAGE;
515 
516  if (pbc != NULL)
517  {
518  static DWORD reported;
519  if (!reported)
520  {
521  FIXME("ignoring IBindCtx %p\n", pbc);
522  reported++;
523  }
524  }
525 
527  {
528  return create_PropertyBag(This, (IPropertyBag**)ppvObj);
529  }
530 
531  return MK_E_NOSTORAGE;
532 }
533 
535  DWORD dwReduceHowFar, IMoniker **ppmkToLeft, IMoniker **ppmkReduced)
536 {
537  TRACE("(%p)->(%p, %d, %p, %p)\n", iface, pbc, dwReduceHowFar, ppmkToLeft, ppmkReduced);
538 
539  if (ppmkToLeft)
540  *ppmkToLeft = NULL;
541  *ppmkReduced = iface;
542 
543  return MK_S_REDUCED_TO_SELF;
544 }
545 
547  BOOL fOnlyIfNotGeneric, IMoniker **ppmkComposite)
548 {
549  FIXME("(%p)->(%p, %s, %p): stub\n", iface, pmkRight, fOnlyIfNotGeneric ? "true" : "false", ppmkComposite);
550 
551  /* FIXME: use CreateGenericComposite? */
552  *ppmkComposite = NULL;
553 
554  return E_NOTIMPL;
555 }
556 
558  IEnumMoniker **ppenumMoniker)
559 {
560  FIXME("(%p)->(%s, %p): stub\n", iface, fForward ? "true" : "false", ppenumMoniker);
561 
562  *ppenumMoniker = NULL;
563 
564  return S_OK;
565 }
566 
568 {
569  CLSID clsid;
570  LPOLESTR this_name, other_name;
571  IBindCtx *bind;
572  HRESULT res;
573 
574  TRACE("(%p)->(%p)\n", iface, pmkOtherMoniker);
575 
576  if (!pmkOtherMoniker)
577  return E_INVALIDARG;
578 
579  IMoniker_GetClassID(pmkOtherMoniker, &clsid);
580  if (!IsEqualCLSID(&clsid, &CLSID_CDeviceMoniker))
581  return S_FALSE;
582 
583  res = CreateBindCtx(0, &bind);
584  if (FAILED(res))
585  return res;
586 
587  res = S_FALSE;
588  if (SUCCEEDED(IMoniker_GetDisplayName(iface, bind, NULL, &this_name)) &&
589  SUCCEEDED(IMoniker_GetDisplayName(pmkOtherMoniker, bind, NULL, &other_name)))
590  {
591  int result = lstrcmpiW(this_name, other_name);
592  CoTaskMemFree(this_name);
593  CoTaskMemFree(other_name);
594  if (!result)
595  res = S_OK;
596  }
597  IBindCtx_Release(bind);
598  return res;
599 }
600 
602 {
603  TRACE("(%p)->(%p)\n", iface, pdwHash);
604 
605  *pdwHash = 0;
606 
607  return S_OK;
608 }
609 
611  IMoniker *pmkToLeft, IMoniker *pmkNewlyRunning)
612 {
613  FIXME("(%p)->(%p, %p, %p): stub\n", iface, pbc, pmkToLeft, pmkNewlyRunning);
614 
615  return S_FALSE;
616 }
617 
619  IMoniker *pmkToLeft, FILETIME *pFileTime)
620 {
621  TRACE("(%p)->(%p, %p, %p)\n", iface, pbc, pmkToLeft, pFileTime);
622 
623  pFileTime->dwLowDateTime = 0xFFFFFFFF;
624  pFileTime->dwHighDateTime = 0x7FFFFFFF;
625 
626  return MK_E_UNAVAILABLE;
627 }
628 
630 {
631  TRACE("(%p)->(%p)\n", iface, ppmk);
632 
633  *ppmk = NULL;
634 
635  return MK_E_NOINVERSE;
636 }
637 
639  IMoniker *pmkOtherMoniker, IMoniker **ppmkPrefix)
640 {
641  TRACE("(%p)->(%p, %p)\n", iface, pmkOtherMoniker, ppmkPrefix);
642 
643  *ppmkPrefix = NULL;
644 
645  return MK_E_NOPREFIX;
646 }
647 
649  IMoniker **ppmkRelPath)
650 {
651  TRACE("(%p)->(%p, %p)\n", iface, pmkOther, ppmkRelPath);
652 
653  *ppmkRelPath = pmkOther;
654 
655  return MK_S_HIM;
656 }
657 
659  IMoniker *pmkToLeft, LPOLESTR *ppszDisplayName)
660 {
661  static const WCHAR swW[] = {'s','w',':',0};
662  static const WCHAR cmW[] = {'c','m',':',0};
664  WCHAR *buffer;
665 
666  TRACE("(%p)->(%p, %p, %p)\n", iface, pbc, pmkToLeft, ppszDisplayName);
667 
668  *ppszDisplayName = NULL;
669 
670  buffer = CoTaskMemAlloc((strlenW(deviceW) + 4 + (This->has_class ? CHARS_IN_GUID : 0)
671  + strlenW(This->name) + 1) * sizeof(WCHAR));
672  if (!buffer)
673  return E_OUTOFMEMORY;
674 
676  if (This->type == DEVICE_FILTER)
677  strcatW(buffer, swW);
678  else if (This->type == DEVICE_CODEC)
679  strcatW(buffer, cmW);
680 
681  if (This->has_class)
682  {
685  }
686  strcatW(buffer, This->name);
687 
688  *ppszDisplayName = buffer;
689  return S_OK;
690 }
691 
693  IMoniker *pmkToLeft, LPOLESTR pszDisplayName, ULONG *pchEaten, IMoniker **ppmkOut)
694 {
695  FIXME("(%p)->(%p, %p, %s, %p, %p)\n", iface, pbc, pmkToLeft, debugstr_w(pszDisplayName), pchEaten, ppmkOut);
696 
697  *pchEaten = 0;
698  *ppmkOut = NULL;
699 
700  return MK_E_SYNTAX;
701 }
702 
704 {
705  TRACE("(%p)->(%p)\n", iface, pdwMksys);
706 
707  return S_FALSE;
708 }
709 
710 static const IMonikerVtbl IMoniker_Vtbl =
711 {
735 };
736 
738 {
739  MediaCatMoniker * pMoniker = NULL;
740  pMoniker = CoTaskMemAlloc(sizeof(MediaCatMoniker));
741  if (!pMoniker)
742  return NULL;
743 
744  pMoniker->IMoniker_iface.lpVtbl = &IMoniker_Vtbl;
745  pMoniker->ref = 0;
746  pMoniker->has_class = FALSE;
747  pMoniker->name = NULL;
748 
750 
752 
753  return pMoniker;
754 }
755 
757 {
758  return CONTAINING_RECORD(iface, EnumMonikerImpl, IEnumMoniker_iface);
759 }
760 
762  void **ppv)
763 {
764  TRACE("(%p)->(%s, %p)\n", iface, debugstr_guid(riid), ppv);
765 
766  if (!ppv)
767  return E_POINTER;
768 
769  if (IsEqualGUID(riid, &IID_IUnknown) ||
771  {
772  *ppv = iface;
773  IEnumMoniker_AddRef(iface);
774  return S_OK;
775  }
776 
777  FIXME("- no interface IID: %s\n", debugstr_guid(riid));
778  *ppv = NULL;
779  return E_NOINTERFACE;
780 }
781 
783 {
786 
787  TRACE("(%p) ref=%d\n", This, ref);
788 
789  return ref;
790 }
791 
793 {
796 
797  TRACE("(%p) ref=%d\n", This, ref);
798 
799  if (!ref)
800  {
801  RegCloseKey(This->sw_key);
802  RegCloseKey(This->cm_key);
805  return 0;
806  }
807  return ref;
808 }
809 
811  ULONG *pceltFetched)
812 {
814  WCHAR buffer[MAX_PATH + 1];
815  LONG res;
816  ULONG fetched = 0;
817  MediaCatMoniker * pMoniker;
818  HKEY hkey;
819 
820  TRACE("(%p)->(%d, %p, %p)\n", iface, celt, rgelt, pceltFetched);
821 
822  while (fetched < celt)
823  {
824  /* FIXME: try PNP devices and DMOs first */
825 
826  /* try DirectShow filters */
827  if (!(res = RegEnumKeyW(This->sw_key, This->sw_index, buffer, sizeof(buffer)/sizeof(WCHAR))))
828  {
829  This->sw_index++;
830  if ((res = RegOpenKeyExW(This->sw_key, buffer, 0, KEY_QUERY_VALUE, &hkey)))
831  break;
832 
833  if (!(pMoniker = DEVENUM_IMediaCatMoniker_Construct()))
834  return E_OUTOFMEMORY;
835 
836  pMoniker->type = DEVICE_FILTER;
837  }
838  /* then try codecs */
839  else if (!(res = RegEnumKeyW(This->cm_key, This->cm_index, buffer, sizeof(buffer)/sizeof(WCHAR))))
840  {
841  This->cm_index++;
842 
843  if ((res = RegOpenKeyExW(This->cm_key, buffer, 0, KEY_QUERY_VALUE, &hkey)))
844  break;
845 
846  if (!(pMoniker = DEVENUM_IMediaCatMoniker_Construct()))
847  return E_OUTOFMEMORY;
848 
849  pMoniker->type = DEVICE_CODEC;
850  }
851  else
852  break;
853 
854  if (!(pMoniker->name = CoTaskMemAlloc((strlenW(buffer) + 1) * sizeof(WCHAR))))
855  {
856  IMoniker_Release(&pMoniker->IMoniker_iface);
857  return E_OUTOFMEMORY;
858  }
859  strcpyW(pMoniker->name, buffer);
860  pMoniker->has_class = TRUE;
861  pMoniker->class = This->class;
862 
863  rgelt[fetched] = &pMoniker->IMoniker_iface;
864  fetched++;
865  }
866 
867  TRACE("-- fetched %d\n", fetched);
868 
869  if (pceltFetched)
870  *pceltFetched = fetched;
871 
872  if (fetched != celt)
873  return S_FALSE;
874  else
875  return S_OK;
876 }
877 
879 {
881 
882  TRACE("(%p)->(%d)\n", iface, celt);
883 
884  while (celt--)
885  {
886  /* FIXME: try PNP devices and DMOs first */
887 
888  /* try DirectShow filters */
889  if (RegEnumKeyW(This->sw_key, This->sw_index, NULL, 0) != ERROR_NO_MORE_ITEMS)
890  {
891  This->sw_index++;
892  }
893  /* then try codecs */
894  else if (RegEnumKeyW(This->cm_key, This->cm_index, NULL, 0) != ERROR_NO_MORE_ITEMS)
895  {
896  This->cm_index++;
897  }
898  else
899  return S_FALSE;
900  }
901 
902  return S_OK;
903 }
904 
906 {
908 
909  TRACE("(%p)->()\n", iface);
910 
911  This->sw_index = 0;
912  This->cm_index = 0;
913 
914  return S_OK;
915 }
916 
918 {
919  FIXME("(%p)->(%p): stub\n", iface, ppenum);
920 
921  return E_NOTIMPL;
922 }
923 
924 /**********************************************************************
925  * IEnumMoniker_Vtbl
926  */
927 static const IEnumMonikerVtbl IEnumMoniker_Vtbl =
928 {
936 };
937 
939 {
940  EnumMonikerImpl * pEnumMoniker = CoTaskMemAlloc(sizeof(EnumMonikerImpl));
941  WCHAR buffer[78];
942 
943  if (!pEnumMoniker)
944  return E_OUTOFMEMORY;
945 
946  pEnumMoniker->IEnumMoniker_iface.lpVtbl = &IEnumMoniker_Vtbl;
947  pEnumMoniker->ref = 1;
948  pEnumMoniker->sw_index = 0;
949  pEnumMoniker->cm_index = 0;
950  pEnumMoniker->class = *class;
951 
956  pEnumMoniker->sw_key = NULL;
957 
961  pEnumMoniker->cm_key = NULL;
962 
963  *ppEnumMoniker = &pEnumMoniker->IEnumMoniker_iface;
964 
966 
967  return S_OK;
968 }
static const IPropertyBagVtbl IPropertyBag_Vtbl
Definition: mediacatenum.c:301
static void DEVENUM_UnlockModule(void)
#define REFIID
Definition: guiddef.h:118
#define TRUE
Definition: types.h:120
#define MK_S_REDUCED_TO_SELF
Definition: winerror.h:2773
static HRESULT WINAPI DEVENUM_IMediaCatMoniker_ParseDisplayName(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, LPOLESTR pszDisplayName, ULONG *pchEaten, IMoniker **ppmkOut)
Definition: mediacatenum.c:692
#define E_NOINTERFACE
Definition: winerror.h:2364
Definition: compat.h:1939
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
static HRESULT WINAPI DEVENUM_IMediaCatMoniker_IsRunning(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, IMoniker *pmkNewlyRunning)
Definition: mediacatenum.c:610
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:422
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define ERROR_SUCCESS
Definition: deptool.c:10
static HRESULT WINAPI DEVENUM_IMediaCatMoniker_IsDirty(IMoniker *iface)
Definition: mediacatenum.c:405
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
Definition: oleaut.c:342
static const WCHAR instanceW[]
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:95
const WCHAR clsid_keyname[6]
Definition: devenum_main.c:45
WCHAR path[MAX_PATH]
Definition: mediacatenum.c:49
#define REG_BINARY
Definition: nt_native.h:1496
enum device_type type
#define MK_E_NOINVERSE
Definition: winerror.h:2793
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: socklife.c:36
REFIID riid
Definition: precomp.h:44
#define REFCLSID
Definition: guiddef.h:117
#define HKEY_CURRENT_USER
Definition: winreg.h:11
static const WCHAR swW[]
Definition: devenum.c:44
const GUID IID_IPersist
Definition: proxy.cpp:14
#define V_ARRAY(A)
Definition: oleauto.h:222
device_type
#define CHARS_IN_GUID
const GUID IID_IEnumMoniker
r received
Definition: btrfs.c:2892
REFIID LPVOID * ppv
Definition: atlbase.h:39
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static HRESULT WINAPI DEVENUM_IMediaCatMoniker_GetDisplayName(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, LPOLESTR *ppszDisplayName)
Definition: mediacatenum.c:658
static ULONG WINAPI DEVENUM_IEnumMoniker_AddRef(IEnumMoniker *iface)
Definition: mediacatenum.c:782
#define ZeroMemory
Definition: winbase.h:1635
GLuint buffer
Definition: glext.h:5915
static HRESULT WINAPI DEVENUM_IMediaCatMoniker_GetTimeOfLastChange(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, FILETIME *pFileTime)
Definition: mediacatenum.c:618
void WINAPI VariantInit(VARIANTARG *pVarg)
Definition: variant.c:571
static LPOLESTR
Definition: stg_prop.c:27
#define lstrlenW
Definition: compat.h:407
#define E_FAIL
Definition: ddrawi.h:102
static const WCHAR cmW[]
Definition: devenum.c:45
#define DWORD
Definition: nt_native.h:44
static HRESULT WINAPI DEVENUM_IMediaCatMoniker_Inverse(IMoniker *iface, IMoniker **ppmk)
Definition: mediacatenum.c:629
Definition: send.c:47
static HRESULT WINAPI DEVENUM_IMediaCatMoniker_ComposeWith(IMoniker *iface, IMoniker *pmkRight, BOOL fOnlyIfNotGeneric, IMoniker **ppmkComposite)
Definition: mediacatenum.c:546
IEnumMoniker IEnumMoniker_iface
Definition: mediacatenum.c:35
static const WCHAR deviceW[]
#define V_I4(A)
Definition: oleauto.h:247
static HRESULT WINAPI DEVENUM_IMediaCatMoniker_IsEqual(IMoniker *iface, IMoniker *pmkOtherMoniker)
Definition: mediacatenum.c:567
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
static ULONG WINAPI DEVENUM_IMediaCatMoniker_Release(IMoniker *iface)
Definition: mediacatenum.c:376
MediaCatMoniker * DEVENUM_IMediaCatMoniker_Construct(void)
Definition: mediacatenum.c:737
static HRESULT WINAPI DEVENUM_IEnumMoniker_QueryInterface(IEnumMoniker *iface, REFIID riid, void **ppv)
Definition: mediacatenum.c:761
static HRESULT WINAPI DEVENUM_IMediaCatMoniker_QueryInterface(IMoniker *iface, REFIID riid, void **ppv)
Definition: mediacatenum.c:343
DWORD dwHighDateTime
Definition: mapidefs.h:66
static HRESULT create_PropertyBag(MediaCatMoniker *mon, IPropertyBag **ppBag)
Definition: mediacatenum.c:310
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
HRESULT WINAPI SafeArrayAccessData(SAFEARRAY *psa, void **ppvData)
Definition: safearray.c:1139
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
const GUID IID_IPersistPropertyBag
Definition: proxy.cpp:11
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3296
#define debugstr_w
Definition: kernel32.h:32
GLenum GLint ref
Definition: glext.h:6028
#define FIXME(fmt,...)
Definition: debug.h:110
static HRESULT WINAPI DEVENUM_IMediaCatMoniker_Load(IMoniker *iface, IStream *pStm)
Definition: mediacatenum.c:412
#define S_FALSE
Definition: winerror.h:2357
HRESULT create_EnumMoniker(REFCLSID class, IEnumMoniker **ppEnumMoniker)
Definition: mediacatenum.c:938
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
const GUID IID_IPropertyBag
static void DEVENUM_LockModule(void)
IPropertyBag IPropertyBag_iface
Definition: mediacatenum.c:46
#define debugstr_guid
Definition: kernel32.h:35
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static const WCHAR backslashW[]
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
struct EnumMonikerImpl EnumMonikerImpl
static ULONG WINAPI DEVENUM_IEnumMoniker_Release(IEnumMoniker *iface)
Definition: mediacatenum.c:792
#define TRACE(s)
Definition: solgame.cpp:4
static HRESULT WINAPI DEVENUM_IEnumMoniker_Skip(IEnumMoniker *iface, ULONG celt)
Definition: mediacatenum.c:878
#define GetProcessHeap()
Definition: compat.h:395
static const WCHAR clsidW[]
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HRESULT WINAPI CreateBindCtx(DWORD reserved, LPBC *ppbc)
Definition: bindctx.c:556
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
const GUID IID_IUnknown
static ULONG WINAPI DEVENUM_IMediaCatMoniker_AddRef(IMoniker *iface)
Definition: mediacatenum.c:366
#define MAX_PATH
Definition: compat.h:26
static HRESULT WINAPI DEVENUM_IMediaCatMoniker_CommonPrefixWith(IMoniker *iface, IMoniker *pmkOtherMoniker, IMoniker **ppmkPrefix)
Definition: mediacatenum.c:638
#define WINAPI
Definition: msvc.h:8
static HRESULT WINAPI DEVENUM_IMediaCatMoniker_BindToStorage(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, REFIID riid, void **ppvObj)
Definition: mediacatenum.c:504
INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax)
Definition: compobj.c:2343
static ULONG WINAPI DEVENUM_IPropertyBag_Release(LPPROPERTYBAG iface)
Definition: mediacatenum.c:96
#define CopyMemory
Definition: winbase.h:1633
static HRESULT WINAPI DEVENUM_IMediaCatMoniker_Enum(IMoniker *iface, BOOL fForward, IEnumMoniker **ppenumMoniker)
Definition: mediacatenum.c:557
static HRESULT WINAPI DEVENUM_IMediaCatMoniker_IsSystemMoniker(IMoniker *iface, DWORD *pdwMksys)
Definition: mediacatenum.c:703
HRESULT WINAPI SafeArrayGetLBound(SAFEARRAY *psa, UINT nDim, LONG *plLbound)
Definition: safearray.c:1068
unsigned long DWORD
Definition: ntddk_ex.h:95
WINE_DEFAULT_DEBUG_CHANNEL(devenum)
static const WCHAR wszActiveMovieKey[]
const GUID IID_IPersistStream
Definition: proxy.cpp:13
static HRESULT WINAPI DEVENUM_IPropertyBag_Read(LPPROPERTYBAG iface, LPCOLESTR pszPropName, VARIANT *pVar, IErrorLog *pErrorLog)
Definition: mediacatenum.c:111
#define V_UI4(A)
Definition: oleauto.h:270
static HRESULT WINAPI DEVENUM_IMediaCatMoniker_Save(IMoniker *iface, IStream *pStm, BOOL fClearDirty)
Definition: mediacatenum.c:419
static ULONG WINAPI DEVENUM_IPropertyBag_AddRef(LPPROPERTYBAG iface)
Definition: mediacatenum.c:84
static RegPropBagImpl * impl_from_IPropertyBag(IPropertyBag *iface)
Definition: mediacatenum.c:53
IMoniker IMoniker_iface
REFCLSID clsid
Definition: msctf.c:84
static HRESULT WINAPI DEVENUM_IMediaCatMoniker_BindToObject(IMoniker *iface, IBindCtx *pbc, IMoniker *pmkToLeft, REFIID riidResult, void **ppvResult)
Definition: mediacatenum.c:435
#define InterlockedDecrement
Definition: armddk.h:52
#define V_VT(A)
Definition: oleauto.h:211
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
LONG WINAPI RegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1199
static HRESULT WINAPI DEVENUM_IEnumMoniker_Next(IEnumMoniker *iface, ULONG celt, IMoniker **rgelt, ULONG *pceltFetched)
Definition: mediacatenum.c:810
#define V_BSTR(A)
Definition: oleauto.h:226
#define MK_E_NOPREFIX
Definition: winerror.h:2795
static MediaCatMoniker * impl_from_IMoniker(IMoniker *iface)
Definition: mediacatenum.c:338
LONG WINAPI RegEnumKeyW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, DWORD cbName)
Definition: reg.c:2416
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3234
SAFEARRAY *WINAPI SafeArrayCreate(VARTYPE vt, UINT cDims, SAFEARRAYBOUND *rgsabound)
Definition: safearray.c:602
#define S_OK
Definition: intsafe.h:59
HRESULT WINAPI SafeArrayGetUBound(SAFEARRAY *psa, UINT nDim, LONG *plUbound)
Definition: safearray.c:1035
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define InterlockedIncrement
Definition: armddk.h:53
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
static HRESULT WINAPI DEVENUM_IMediaCatMoniker_GetSizeMax(IMoniker *iface, ULARGE_INTEGER *pcbSize)
Definition: mediacatenum.c:426
static HRESULT WINAPI DEVENUM_IMediaCatMoniker_RelativePathTo(IMoniker *iface, IMoniker *pmkOther, IMoniker **ppmkRelPath)
Definition: mediacatenum.c:648
#define E_NOTIMPL
Definition: ddrawi.h:99
Definition: services.c:325
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
static HRESULT WINAPI DEVENUM_IMediaCatMoniker_GetClassID(IMoniker *iface, CLSID *pClassID)
Definition: mediacatenum.c:391
static EnumMonikerImpl * impl_from_IEnumMoniker(IEnumMoniker *iface)
Definition: mediacatenum.c:756
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4021
#define MK_E_UNAVAILABLE
Definition: winerror.h:2784
GLuint res
Definition: glext.h:9613
HRESULT WINAPI CLSIDFromString(LPCOLESTR idstr, LPCLSID id)
Definition: compobj.c:2247
unsigned int ULONG
Definition: retypes.h:1
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define MK_E_NOSTORAGE
Definition: winerror.h:2794
#define HKEY_CLASSES_ROOT
Definition: winreg.h:10
#define MK_E_SYNTAX
Definition: winerror.h:2785
static HRESULT WINAPI DEVENUM_IMediaCatMoniker_Reduce(IMoniker *iface, IBindCtx *pbc, DWORD dwReduceHowFar, IMoniker **ppmkToLeft, IMoniker **ppmkReduced)
Definition: mediacatenum.c:534
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1827
#define E_POINTER
Definition: winerror.h:2365
#define STG_E_CANTSAVE
Definition: winerror.h:2591
GLuint64EXT * result
Definition: glext.h:11304
#define REG_DWORD
Definition: sdbapi.c:596
#define IsEqualCLSID(rclsid1, rclsid2)
Definition: guiddef.h:96
static HRESULT WINAPI DEVENUM_IPropertyBag_Write(LPPROPERTYBAG iface, LPCOLESTR pszPropName, VARIANT *pVar)
Definition: mediacatenum.c:234
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:406
static HRESULT WINAPI DEVENUM_IMediaCatMoniker_Hash(IMoniker *iface, DWORD *pdwHash)
Definition: mediacatenum.c:601
static const IEnumMonikerVtbl IEnumMoniker_Vtbl
Definition: mediacatenum.c:927
#define HeapFree(x, y, z)
Definition: compat.h:394
DWORD dwLowDateTime
Definition: mapidefs.h:65
static HRESULT WINAPI DEVENUM_IEnumMoniker_Reset(IEnumMoniker *iface)
Definition: mediacatenum.c:905
HRESULT WINAPI SafeArrayUnaccessData(SAFEARRAY *psa)
Definition: safearray.c:1170
#define SUCCEEDED(hr)
Definition: intsafe.h:57
enum device_type type
Definition: mediacatenum.c:48
static HRESULT WINAPI DEVENUM_IPropertyBag_QueryInterface(LPPROPERTYBAG iface, REFIID riid, LPVOID *ppvObj)
Definition: mediacatenum.c:58
static HRESULT WINAPI DEVENUM_IEnumMoniker_Clone(IEnumMoniker *iface, IEnumMoniker **ppenum)
Definition: mediacatenum.c:917
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1019
static const IMonikerVtbl IMoniker_Vtbl
Definition: mediacatenum.c:710
#define REG_SZ
Definition: layer.c:22
#define MK_S_HIM
Definition: winerror.h:2775