2 * IEnumMoniker implementation for DEVENUM.dll
4 * Copyright (C) 2002 Robert Shearman
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.
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.
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
21 * - Implements IEnumMoniker interface which enumerates through moniker
22 * objects created from HKEY_CLASSES/CLSID/{DEVICE_CLSID}/Instance
25 #include "devenum_private.h"
29 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(devenum
);
35 IEnumMoniker IEnumMoniker_iface
;
43 IPropertyBag IPropertyBag_iface
;
49 static inline RegPropBagImpl
*impl_from_IPropertyBag(IPropertyBag
*iface
)
51 return CONTAINING_RECORD(iface
, RegPropBagImpl
, IPropertyBag_iface
);
54 static HRESULT WINAPI
DEVENUM_IPropertyBag_QueryInterface(
59 RegPropBagImpl
*This
= impl_from_IPropertyBag(iface
);
61 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), ppvObj
);
63 if (This
== NULL
|| ppvObj
== NULL
) return E_POINTER
;
65 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
66 IsEqualGUID(riid
, &IID_IPropertyBag
))
69 IPropertyBag_AddRef(iface
);
73 FIXME("- no interface IID: %s\n", debugstr_guid(riid
));
77 /**********************************************************************
78 * DEVENUM_IPropertyBag_AddRef (also IUnknown)
80 static ULONG WINAPI
DEVENUM_IPropertyBag_AddRef(LPPROPERTYBAG iface
)
82 RegPropBagImpl
*This
= impl_from_IPropertyBag(iface
);
84 TRACE("(%p)->() AddRef from %d\n", iface
, This
->ref
);
86 return InterlockedIncrement(&This
->ref
);
89 /**********************************************************************
90 * DEVENUM_IPropertyBag_Release (also IUnknown)
92 static ULONG WINAPI
DEVENUM_IPropertyBag_Release(LPPROPERTYBAG iface
)
94 RegPropBagImpl
*This
= impl_from_IPropertyBag(iface
);
97 TRACE("(%p)->() ReleaseThis->ref from %d\n", iface
, This
->ref
);
99 ref
= InterlockedDecrement(&This
->ref
);
101 RegCloseKey(This
->hkey
);
103 DEVENUM_UnlockModule();
108 static HRESULT WINAPI
DEVENUM_IPropertyBag_Read(
110 LPCOLESTR pszPropName
,
112 IErrorLog
* pErrorLog
)
117 RegPropBagImpl
*This
= impl_from_IPropertyBag(iface
);
121 TRACE("(%p)->(%s, %p, %p)\n", This
, debugstr_w(pszPropName
), pVar
, pErrorLog
);
123 if (!pszPropName
|| !pVar
)
126 reswin32
= RegQueryValueExW(This
->hkey
, pszPropName
, NULL
, NULL
, NULL
, &received
);
127 res
= HRESULT_FROM_WIN32(reswin32
);
131 pData
= HeapAlloc(GetProcessHeap(), 0, received
);
133 /* work around a GCC bug that occurs here unless we use the reswin32 variable as well */
134 reswin32
= RegQueryValueExW(This
->hkey
, pszPropName
, NULL
, &type
, pData
, &received
);
135 res
= HRESULT_FROM_WIN32(reswin32
);
140 res
= E_INVALIDARG
; /* assume we cannot coerce into right type */
142 TRACE("Read %d bytes (%s)\n", received
, type
== REG_SZ
? debugstr_w(pData
) : "binary data");
150 V_UNION(pVar
, bstrVal
) = CoTaskMemAlloc(received
);
151 memcpy(V_UNION(pVar
, bstrVal
), pData
, received
);
155 V_VT(pVar
) = VT_BSTR
;
158 V_UNION(pVar
, bstrVal
) = SysAllocStringLen(pData
, received
/sizeof(WCHAR
) - 1);
164 TRACE("REG_DWORD: %x\n", *(DWORD
*)pData
);
172 V_UNION(pVar
, ulVal
) = *(DWORD
*)pData
;
179 SAFEARRAYBOUND bound
;
180 void * pArrayElements
;
182 bound
.cElements
= received
;
183 TRACE("REG_BINARY: len = %d\n", received
);
187 V_VT(pVar
) = VT_ARRAY
| VT_UI1
;
189 case VT_ARRAY
| VT_UI1
:
190 if (!(V_UNION(pVar
, parray
) = SafeArrayCreate(VT_UI1
, 1, &bound
)))
197 if (res
== E_INVALIDARG
)
200 res
= SafeArrayAccessData(V_UNION(pVar
, parray
), &pArrayElements
);
204 CopyMemory(pArrayElements
, pData
, received
);
205 res
= SafeArrayUnaccessData(V_UNION(pVar
, parray
));
209 if (res
== E_INVALIDARG
)
210 FIXME("Variant type %x not supported for regtype %x\n", V_VT(pVar
), type
);
213 HeapFree(GetProcessHeap(), 0, pData
);
215 TRACE("<- %x\n", res
);
219 static HRESULT WINAPI
DEVENUM_IPropertyBag_Write(
221 LPCOLESTR pszPropName
,
224 RegPropBagImpl
*This
= impl_from_IPropertyBag(iface
);
225 LPVOID lpData
= NULL
;
230 TRACE("(%p)->(%s, %p)\n", This
, debugstr_w(pszPropName
), pVar
);
235 TRACE("writing %s\n", debugstr_w(V_UNION(pVar
, bstrVal
)));
236 lpData
= V_UNION(pVar
, bstrVal
);
238 cbData
= (lstrlenW(V_UNION(pVar
, bstrVal
)) + 1) * sizeof(WCHAR
);
242 TRACE("writing %u\n", V_UNION(pVar
, ulVal
));
243 lpData
= &V_UNION(pVar
, ulVal
);
245 cbData
= sizeof(DWORD
);
247 case VT_ARRAY
| VT_UI1
:
252 res
= SafeArrayGetLBound(V_UNION(pVar
, parray
), 1, &lLbound
);
253 res
= SafeArrayGetUBound(V_UNION(pVar
, parray
), 1, &lUbound
);
254 cbData
= (lUbound
- lLbound
+ 1) /* * sizeof(BYTE)*/;
255 TRACE("cbData: %d\n", cbData
);
256 res
= SafeArrayAccessData(V_UNION(pVar
, parray
), &lpData
);
260 FIXME("Variant type %d not handled\n", V_VT(pVar
));
264 if (RegSetValueExW(This
->hkey
,
266 dwType
, lpData
, cbData
) != ERROR_SUCCESS
)
269 if (V_VT(pVar
) & VT_ARRAY
)
270 res
= SafeArrayUnaccessData(V_UNION(pVar
, parray
));
275 static const IPropertyBagVtbl IPropertyBag_Vtbl
=
277 DEVENUM_IPropertyBag_QueryInterface
,
278 DEVENUM_IPropertyBag_AddRef
,
279 DEVENUM_IPropertyBag_Release
,
280 DEVENUM_IPropertyBag_Read
,
281 DEVENUM_IPropertyBag_Write
284 static HRESULT
DEVENUM_IPropertyBag_Construct(HANDLE hkey
, IPropertyBag
**ppBag
)
286 RegPropBagImpl
* rpb
= CoTaskMemAlloc(sizeof(RegPropBagImpl
));
288 return E_OUTOFMEMORY
;
289 rpb
->IPropertyBag_iface
.lpVtbl
= &IPropertyBag_Vtbl
;
292 *ppBag
= &rpb
->IPropertyBag_iface
;
293 DEVENUM_LockModule();
298 static inline MediaCatMoniker
*impl_from_IMoniker(IMoniker
*iface
)
300 return CONTAINING_RECORD(iface
, MediaCatMoniker
, IMoniker_iface
);
303 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_QueryInterface(IMoniker
*iface
, REFIID riid
,
306 TRACE("\n\tIID:\t%s\n",debugstr_guid(riid
));
311 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
312 IsEqualGUID(riid
, &IID_IPersist
) ||
313 IsEqualGUID(riid
, &IID_IPersistStream
) ||
314 IsEqualGUID(riid
, &IID_IMoniker
))
317 IMoniker_AddRef(iface
);
321 FIXME("- no interface IID: %s\n", debugstr_guid(riid
));
323 return E_NOINTERFACE
;
326 static ULONG WINAPI
DEVENUM_IMediaCatMoniker_AddRef(IMoniker
*iface
)
328 MediaCatMoniker
*This
= impl_from_IMoniker(iface
);
329 ULONG ref
= InterlockedIncrement(&This
->ref
);
331 TRACE("(%p) ref=%d\n", This
, ref
);
336 static ULONG WINAPI
DEVENUM_IMediaCatMoniker_Release(IMoniker
*iface
)
338 MediaCatMoniker
*This
= impl_from_IMoniker(iface
);
339 ULONG ref
= InterlockedDecrement(&This
->ref
);
341 TRACE("(%p) ref=%d\n", This
, ref
);
344 RegCloseKey(This
->hkey
);
346 DEVENUM_UnlockModule();
351 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_GetClassID(IMoniker
*iface
, CLSID
*pClassID
)
353 MediaCatMoniker
*This
= impl_from_IMoniker(iface
);
355 FIXME("(%p)->(%p): stub\n", This
, pClassID
);
357 if (pClassID
== NULL
)
363 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_IsDirty(IMoniker
*iface
)
365 FIXME("(%p)->(): stub\n", iface
);
370 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_Load(IMoniker
*iface
, IStream
*pStm
)
372 FIXME("(%p)->(%p): stub\n", iface
, pStm
);
377 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_Save(IMoniker
*iface
, IStream
*pStm
, BOOL fClearDirty
)
379 FIXME("(%p)->(%p, %s): stub\n", iface
, pStm
, fClearDirty
? "true" : "false");
381 return STG_E_CANTSAVE
;
384 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_GetSizeMax(IMoniker
*iface
, ULARGE_INTEGER
*pcbSize
)
386 FIXME("(%p)->(%p): stub\n", iface
, pcbSize
);
388 ZeroMemory(pcbSize
, sizeof(*pcbSize
));
393 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_BindToObject(IMoniker
*iface
, IBindCtx
*pbc
,
394 IMoniker
*pmkToLeft
, REFIID riidResult
, void **ppvResult
)
396 MediaCatMoniker
*This
= impl_from_IMoniker(iface
);
397 IUnknown
* pObj
= NULL
;
398 IPropertyBag
* pProp
= NULL
;
401 HRESULT res
= E_FAIL
;
403 TRACE("(%p)->(%p, %p, %s, %p)\n", This
, pbc
, pmkToLeft
, debugstr_guid(riidResult
), ppvResult
);
410 /* first activation of this class */
412 res
=IMoniker_BindToStorage(iface
, NULL
, NULL
, &IID_IPropertyBag
, &pvptr
);
416 V_VT(&var
) = VT_LPWSTR
;
417 res
= IPropertyBag_Read(pProp
, clsid_keyname
, &var
, NULL
);
421 res
= CLSIDFromString(V_UNION(&var
,bstrVal
), &clsID
);
422 CoTaskMemFree(V_UNION(&var
, bstrVal
));
426 res
=CoCreateInstance(&clsID
,NULL
,CLSCTX_ALL
,&IID_IUnknown
,&pvptr
);
433 /* get the requested interface from the loaded class */
438 res2
= IUnknown_QueryInterface(pObj
, &IID_IPersistPropertyBag
, &ppv
);
439 if (SUCCEEDED(res2
)) {
440 res
= IPersistPropertyBag_Load((IPersistPropertyBag
*) ppv
, pProp
, NULL
);
441 IPersistPropertyBag_Release((IPersistPropertyBag
*) ppv
);
445 res
= IUnknown_QueryInterface(pObj
,riidResult
,ppvResult
);
446 IUnknown_Release(pObj
);
451 IPropertyBag_Release(pProp
);
454 TRACE("<- 0x%x\n", res
);
459 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_BindToStorage(IMoniker
*iface
, IBindCtx
*pbc
,
460 IMoniker
*pmkToLeft
, REFIID riid
, void **ppvObj
)
462 MediaCatMoniker
*This
= impl_from_IMoniker(iface
);
464 TRACE("(%p)->(%p, %p, %s, %p)\n", This
, pbc
, pmkToLeft
, debugstr_guid(riid
), ppvObj
);
468 if (pbc
|| pmkToLeft
)
469 return MK_E_NOSTORAGE
;
471 if (IsEqualGUID(riid
, &IID_IPropertyBag
))
474 DuplicateHandle(GetCurrentProcess(), This
->hkey
, GetCurrentProcess(), &hkey
, 0, 0, DUPLICATE_SAME_ACCESS
);
475 return DEVENUM_IPropertyBag_Construct(hkey
, (IPropertyBag
**)ppvObj
);
478 return MK_E_NOSTORAGE
;
481 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_Reduce(IMoniker
*iface
, IBindCtx
*pbc
,
482 DWORD dwReduceHowFar
, IMoniker
**ppmkToLeft
, IMoniker
**ppmkReduced
)
484 TRACE("(%p)->(%p, %d, %p, %p)\n", iface
, pbc
, dwReduceHowFar
, ppmkToLeft
, ppmkReduced
);
488 *ppmkReduced
= iface
;
490 return MK_S_REDUCED_TO_SELF
;
493 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_ComposeWith(IMoniker
*iface
, IMoniker
*pmkRight
,
494 BOOL fOnlyIfNotGeneric
, IMoniker
**ppmkComposite
)
496 FIXME("(%p)->(%p, %s, %p): stub\n", iface
, pmkRight
, fOnlyIfNotGeneric
? "true" : "false", ppmkComposite
);
498 /* FIXME: use CreateGenericComposite? */
499 *ppmkComposite
= NULL
;
504 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_Enum(IMoniker
*iface
, BOOL fForward
,
505 IEnumMoniker
**ppenumMoniker
)
507 FIXME("(%p)->(%s, %p): stub\n", iface
, fForward
? "true" : "false", ppenumMoniker
);
509 *ppenumMoniker
= NULL
;
514 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_IsEqual(IMoniker
*iface
, IMoniker
*pmkOtherMoniker
)
516 FIXME("(%p)->(%p): stub\n", iface
, pmkOtherMoniker
);
521 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_Hash(IMoniker
*iface
, DWORD
*pdwHash
)
523 TRACE("(%p)->(%p)\n", iface
, pdwHash
);
530 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_IsRunning(IMoniker
*iface
, IBindCtx
*pbc
,
531 IMoniker
*pmkToLeft
, IMoniker
*pmkNewlyRunning
)
533 FIXME("(%p)->(%p, %p, %p): stub\n", iface
, pbc
, pmkToLeft
, pmkNewlyRunning
);
538 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_GetTimeOfLastChange(IMoniker
*iface
, IBindCtx
*pbc
,
539 IMoniker
*pmkToLeft
, FILETIME
*pFileTime
)
541 TRACE("(%p)->(%p, %p, %p)\n", iface
, pbc
, pmkToLeft
, pFileTime
);
543 pFileTime
->dwLowDateTime
= 0xFFFFFFFF;
544 pFileTime
->dwHighDateTime
= 0x7FFFFFFF;
546 return MK_E_UNAVAILABLE
;
549 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_Inverse(IMoniker
*iface
, IMoniker
**ppmk
)
551 TRACE("(%p)->(%p)\n", iface
, ppmk
);
555 return MK_E_NOINVERSE
;
558 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_CommonPrefixWith(IMoniker
*iface
,
559 IMoniker
*pmkOtherMoniker
, IMoniker
**ppmkPrefix
)
561 TRACE("(%p)->(%p, %p)\n", iface
, pmkOtherMoniker
, ppmkPrefix
);
565 return MK_E_NOPREFIX
;
568 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_RelativePathTo(IMoniker
*iface
, IMoniker
*pmkOther
,
569 IMoniker
**ppmkRelPath
)
571 TRACE("(%p)->(%p, %p)\n", iface
, pmkOther
, ppmkRelPath
);
573 *ppmkRelPath
= pmkOther
;
578 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_GetDisplayName(IMoniker
*iface
, IBindCtx
*pbc
,
579 IMoniker
*pmkToLeft
, LPOLESTR
*ppszDisplayName
)
581 MediaCatMoniker
*This
= impl_from_IMoniker(iface
);
582 WCHAR wszBuffer
[MAX_PATH
];
583 static const WCHAR wszFriendlyName
[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
584 LONG received
= sizeof(wszFriendlyName
);
586 TRACE("(%p)->(%p, %p, %p)\n", iface
, pbc
, pmkToLeft
, ppszDisplayName
);
588 *ppszDisplayName
= NULL
;
590 /* FIXME: should this be the weird stuff we have to parse in IParseDisplayName? */
591 if (RegQueryValueW(This
->hkey
, wszFriendlyName
, wszBuffer
, &received
) == ERROR_SUCCESS
)
593 *ppszDisplayName
= CoTaskMemAlloc(received
);
594 strcpyW(*ppszDisplayName
, wszBuffer
);
601 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_ParseDisplayName(IMoniker
*iface
, IBindCtx
*pbc
,
602 IMoniker
*pmkToLeft
, LPOLESTR pszDisplayName
, ULONG
*pchEaten
, IMoniker
**ppmkOut
)
604 FIXME("(%p)->(%p, %p, %s, %p, %p)\n", iface
, pbc
, pmkToLeft
, debugstr_w(pszDisplayName
), pchEaten
, ppmkOut
);
612 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_IsSystemMoniker(IMoniker
*iface
, DWORD
*pdwMksys
)
614 TRACE("(%p)->(%p)\n", iface
, pdwMksys
);
619 static const IMonikerVtbl IMoniker_Vtbl
=
621 DEVENUM_IMediaCatMoniker_QueryInterface
,
622 DEVENUM_IMediaCatMoniker_AddRef
,
623 DEVENUM_IMediaCatMoniker_Release
,
624 DEVENUM_IMediaCatMoniker_GetClassID
,
625 DEVENUM_IMediaCatMoniker_IsDirty
,
626 DEVENUM_IMediaCatMoniker_Load
,
627 DEVENUM_IMediaCatMoniker_Save
,
628 DEVENUM_IMediaCatMoniker_GetSizeMax
,
629 DEVENUM_IMediaCatMoniker_BindToObject
,
630 DEVENUM_IMediaCatMoniker_BindToStorage
,
631 DEVENUM_IMediaCatMoniker_Reduce
,
632 DEVENUM_IMediaCatMoniker_ComposeWith
,
633 DEVENUM_IMediaCatMoniker_Enum
,
634 DEVENUM_IMediaCatMoniker_IsEqual
,
635 DEVENUM_IMediaCatMoniker_Hash
,
636 DEVENUM_IMediaCatMoniker_IsRunning
,
637 DEVENUM_IMediaCatMoniker_GetTimeOfLastChange
,
638 DEVENUM_IMediaCatMoniker_Inverse
,
639 DEVENUM_IMediaCatMoniker_CommonPrefixWith
,
640 DEVENUM_IMediaCatMoniker_RelativePathTo
,
641 DEVENUM_IMediaCatMoniker_GetDisplayName
,
642 DEVENUM_IMediaCatMoniker_ParseDisplayName
,
643 DEVENUM_IMediaCatMoniker_IsSystemMoniker
646 MediaCatMoniker
* DEVENUM_IMediaCatMoniker_Construct(void)
648 MediaCatMoniker
* pMoniker
= NULL
;
649 pMoniker
= CoTaskMemAlloc(sizeof(MediaCatMoniker
));
653 pMoniker
->IMoniker_iface
.lpVtbl
= &IMoniker_Vtbl
;
655 pMoniker
->hkey
= NULL
;
657 DEVENUM_IMediaCatMoniker_AddRef(&pMoniker
->IMoniker_iface
);
659 DEVENUM_LockModule();
664 static inline EnumMonikerImpl
*impl_from_IEnumMoniker(IEnumMoniker
*iface
)
666 return CONTAINING_RECORD(iface
, EnumMonikerImpl
, IEnumMoniker_iface
);
669 static HRESULT WINAPI
DEVENUM_IEnumMoniker_QueryInterface(IEnumMoniker
*iface
, REFIID riid
,
672 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), ppv
);
677 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
678 IsEqualGUID(riid
, &IID_IEnumMoniker
))
681 IEnumMoniker_AddRef(iface
);
685 FIXME("- no interface IID: %s\n", debugstr_guid(riid
));
687 return E_NOINTERFACE
;
690 static ULONG WINAPI
DEVENUM_IEnumMoniker_AddRef(IEnumMoniker
*iface
)
692 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(iface
);
693 ULONG ref
= InterlockedIncrement(&This
->ref
);
695 TRACE("(%p) ref=%d\n", This
, ref
);
700 static ULONG WINAPI
DEVENUM_IEnumMoniker_Release(IEnumMoniker
*iface
)
702 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(iface
);
703 ULONG ref
= InterlockedDecrement(&This
->ref
);
705 TRACE("(%p) ref=%d\n", This
, ref
);
709 RegCloseKey(This
->hkey
);
711 DEVENUM_UnlockModule();
717 static HRESULT WINAPI
DEVENUM_IEnumMoniker_Next(IEnumMoniker
*iface
, ULONG celt
, IMoniker
**rgelt
,
720 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(iface
);
721 WCHAR buffer
[MAX_PATH
+ 1];
724 MediaCatMoniker
* pMoniker
;
726 TRACE("(%p)->(%d, %p, %p)\n", iface
, celt
, rgelt
, pceltFetched
);
728 while (fetched
< celt
)
730 res
= RegEnumKeyW(This
->hkey
, This
->index
, buffer
, sizeof(buffer
) / sizeof(WCHAR
));
731 if (res
!= ERROR_SUCCESS
)
735 pMoniker
= DEVENUM_IMediaCatMoniker_Construct();
737 return E_OUTOFMEMORY
;
739 if (RegOpenKeyW(This
->hkey
, buffer
, &pMoniker
->hkey
) != ERROR_SUCCESS
)
741 IMoniker_Release(&pMoniker
->IMoniker_iface
);
744 rgelt
[fetched
] = &pMoniker
->IMoniker_iface
;
748 This
->index
+= fetched
;
750 TRACE("-- fetched %d\n", fetched
);
753 *pceltFetched
= fetched
;
761 static HRESULT WINAPI
DEVENUM_IEnumMoniker_Skip(IEnumMoniker
*iface
, ULONG celt
)
763 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(iface
);
766 TRACE("(%p)->(%d)\n", iface
, celt
);
768 /* Before incrementing, check if there are any more values to run thru.
769 Some programs use the Skip() function to get the amount of devices */
770 if(RegQueryInfoKeyW(This
->hkey
, NULL
, NULL
, NULL
, &subKeys
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
) != ERROR_SUCCESS
)
774 if((This
->index
+ celt
) >= subKeys
)
784 static HRESULT WINAPI
DEVENUM_IEnumMoniker_Reset(IEnumMoniker
*iface
)
786 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(iface
);
788 TRACE("(%p)->()\n", iface
);
795 static HRESULT WINAPI
DEVENUM_IEnumMoniker_Clone(IEnumMoniker
*iface
, IEnumMoniker
**ppenum
)
797 FIXME("(%p)->(%p): stub\n", iface
, ppenum
);
802 /**********************************************************************
805 static const IEnumMonikerVtbl IEnumMoniker_Vtbl
=
807 DEVENUM_IEnumMoniker_QueryInterface
,
808 DEVENUM_IEnumMoniker_AddRef
,
809 DEVENUM_IEnumMoniker_Release
,
810 DEVENUM_IEnumMoniker_Next
,
811 DEVENUM_IEnumMoniker_Skip
,
812 DEVENUM_IEnumMoniker_Reset
,
813 DEVENUM_IEnumMoniker_Clone
816 HRESULT
DEVENUM_IEnumMoniker_Construct(HKEY hkey
, IEnumMoniker
** ppEnumMoniker
)
818 EnumMonikerImpl
* pEnumMoniker
= CoTaskMemAlloc(sizeof(EnumMonikerImpl
));
820 return E_OUTOFMEMORY
;
822 pEnumMoniker
->IEnumMoniker_iface
.lpVtbl
= &IEnumMoniker_Vtbl
;
823 pEnumMoniker
->ref
= 1;
824 pEnumMoniker
->index
= 0;
825 pEnumMoniker
->hkey
= hkey
;
827 *ppEnumMoniker
= &pEnumMoniker
->IEnumMoniker_iface
;
829 DEVENUM_LockModule();