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
;
45 IPropertyBag IPropertyBag_iface
;
51 static inline RegPropBagImpl
*impl_from_IPropertyBag(IPropertyBag
*iface
)
53 return CONTAINING_RECORD(iface
, RegPropBagImpl
, IPropertyBag_iface
);
56 static HRESULT WINAPI
DEVENUM_IPropertyBag_QueryInterface(
61 RegPropBagImpl
*This
= impl_from_IPropertyBag(iface
);
63 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), ppvObj
);
65 if (This
== NULL
|| ppvObj
== NULL
) return E_POINTER
;
67 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
68 IsEqualGUID(riid
, &IID_IPropertyBag
))
71 IPropertyBag_AddRef(iface
);
75 FIXME("- no interface IID: %s\n", debugstr_guid(riid
));
79 /**********************************************************************
80 * DEVENUM_IPropertyBag_AddRef (also IUnknown)
82 static ULONG WINAPI
DEVENUM_IPropertyBag_AddRef(LPPROPERTYBAG iface
)
84 RegPropBagImpl
*This
= impl_from_IPropertyBag(iface
);
86 TRACE("(%p)->() AddRef from %d\n", iface
, This
->ref
);
88 return InterlockedIncrement(&This
->ref
);
91 /**********************************************************************
92 * DEVENUM_IPropertyBag_Release (also IUnknown)
94 static ULONG WINAPI
DEVENUM_IPropertyBag_Release(LPPROPERTYBAG iface
)
96 RegPropBagImpl
*This
= impl_from_IPropertyBag(iface
);
99 TRACE("(%p)->() ReleaseThis->ref from %d\n", iface
, This
->ref
);
101 ref
= InterlockedDecrement(&This
->ref
);
103 RegCloseKey(This
->hkey
);
105 DEVENUM_UnlockModule();
110 static HRESULT WINAPI
DEVENUM_IPropertyBag_Read(
112 LPCOLESTR pszPropName
,
114 IErrorLog
* pErrorLog
)
119 RegPropBagImpl
*This
= impl_from_IPropertyBag(iface
);
123 TRACE("(%p)->(%s, %p, %p)\n", This
, debugstr_w(pszPropName
), pVar
, pErrorLog
);
125 if (!pszPropName
|| !pVar
)
128 reswin32
= RegQueryValueExW(This
->hkey
, pszPropName
, NULL
, NULL
, NULL
, &received
);
129 res
= HRESULT_FROM_WIN32(reswin32
);
133 pData
= HeapAlloc(GetProcessHeap(), 0, received
);
135 /* work around a GCC bug that occurs here unless we use the reswin32 variable as well */
136 reswin32
= RegQueryValueExW(This
->hkey
, pszPropName
, NULL
, &type
, pData
, &received
);
137 res
= HRESULT_FROM_WIN32(reswin32
);
142 res
= E_INVALIDARG
; /* assume we cannot coerce into right type */
144 TRACE("Read %d bytes (%s)\n", received
, type
== REG_SZ
? debugstr_w(pData
) : "binary data");
152 V_BSTR(pVar
) = CoTaskMemAlloc(received
);
153 memcpy(V_BSTR(pVar
), pData
, received
);
157 V_VT(pVar
) = VT_BSTR
;
160 V_BSTR(pVar
) = SysAllocStringLen(pData
, received
/sizeof(WCHAR
) - 1);
166 TRACE("REG_DWORD: %x\n", *(DWORD
*)pData
);
174 V_I4(pVar
) = *(DWORD
*)pData
;
181 SAFEARRAYBOUND bound
;
182 void * pArrayElements
;
184 bound
.cElements
= received
;
185 TRACE("REG_BINARY: len = %d\n", received
);
189 V_VT(pVar
) = VT_ARRAY
| VT_UI1
;
191 case VT_ARRAY
| VT_UI1
:
192 if (!(V_ARRAY(pVar
) = SafeArrayCreate(VT_UI1
, 1, &bound
)))
199 if (res
== E_INVALIDARG
)
202 res
= SafeArrayAccessData(V_ARRAY(pVar
), &pArrayElements
);
206 CopyMemory(pArrayElements
, pData
, received
);
207 res
= SafeArrayUnaccessData(V_ARRAY(pVar
));
211 if (res
== E_INVALIDARG
)
212 FIXME("Variant type %x not supported for regtype %x\n", V_VT(pVar
), type
);
215 HeapFree(GetProcessHeap(), 0, pData
);
217 TRACE("<- %x\n", res
);
221 static HRESULT WINAPI
DEVENUM_IPropertyBag_Write(
223 LPCOLESTR pszPropName
,
226 RegPropBagImpl
*This
= impl_from_IPropertyBag(iface
);
227 LPVOID lpData
= NULL
;
232 TRACE("(%p)->(%s, %p)\n", This
, debugstr_w(pszPropName
), pVar
);
238 TRACE("writing %s\n", debugstr_w(V_BSTR(pVar
)));
239 lpData
= V_BSTR(pVar
);
241 cbData
= (lstrlenW(V_BSTR(pVar
)) + 1) * sizeof(WCHAR
);
245 TRACE("writing %u\n", V_UI4(pVar
));
246 lpData
= &V_UI4(pVar
);
248 cbData
= sizeof(DWORD
);
250 case VT_ARRAY
| VT_UI1
:
255 res
= SafeArrayGetLBound(V_ARRAY(pVar
), 1, &lLbound
);
256 res
= SafeArrayGetUBound(V_ARRAY(pVar
), 1, &lUbound
);
257 cbData
= (lUbound
- lLbound
+ 1) /* * sizeof(BYTE)*/;
258 TRACE("cbData: %d\n", cbData
);
259 res
= SafeArrayAccessData(V_ARRAY(pVar
), &lpData
);
263 FIXME("Variant type %d not handled\n", V_VT(pVar
));
267 if (RegSetValueExW(This
->hkey
,
269 dwType
, lpData
, cbData
) != ERROR_SUCCESS
)
272 if (V_VT(pVar
) & VT_ARRAY
)
273 res
= SafeArrayUnaccessData(V_ARRAY(pVar
));
278 static const IPropertyBagVtbl IPropertyBag_Vtbl
=
280 DEVENUM_IPropertyBag_QueryInterface
,
281 DEVENUM_IPropertyBag_AddRef
,
282 DEVENUM_IPropertyBag_Release
,
283 DEVENUM_IPropertyBag_Read
,
284 DEVENUM_IPropertyBag_Write
287 static HRESULT
DEVENUM_IPropertyBag_Construct(HANDLE hkey
, IPropertyBag
**ppBag
)
289 RegPropBagImpl
* rpb
= CoTaskMemAlloc(sizeof(RegPropBagImpl
));
291 return E_OUTOFMEMORY
;
292 rpb
->IPropertyBag_iface
.lpVtbl
= &IPropertyBag_Vtbl
;
295 *ppBag
= &rpb
->IPropertyBag_iface
;
296 DEVENUM_LockModule();
301 static inline MediaCatMoniker
*impl_from_IMoniker(IMoniker
*iface
)
303 return CONTAINING_RECORD(iface
, MediaCatMoniker
, IMoniker_iface
);
306 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_QueryInterface(IMoniker
*iface
, REFIID riid
,
309 TRACE("\n\tIID:\t%s\n",debugstr_guid(riid
));
314 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
315 IsEqualGUID(riid
, &IID_IPersist
) ||
316 IsEqualGUID(riid
, &IID_IPersistStream
) ||
317 IsEqualGUID(riid
, &IID_IMoniker
))
320 IMoniker_AddRef(iface
);
324 FIXME("- no interface IID: %s\n", debugstr_guid(riid
));
326 return E_NOINTERFACE
;
329 static ULONG WINAPI
DEVENUM_IMediaCatMoniker_AddRef(IMoniker
*iface
)
331 MediaCatMoniker
*This
= impl_from_IMoniker(iface
);
332 ULONG ref
= InterlockedIncrement(&This
->ref
);
334 TRACE("(%p) ref=%d\n", This
, ref
);
339 static ULONG WINAPI
DEVENUM_IMediaCatMoniker_Release(IMoniker
*iface
)
341 MediaCatMoniker
*This
= impl_from_IMoniker(iface
);
342 ULONG ref
= InterlockedDecrement(&This
->ref
);
344 TRACE("(%p) ref=%d\n", This
, ref
);
347 RegCloseKey(This
->hkey
);
349 DEVENUM_UnlockModule();
354 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_GetClassID(IMoniker
*iface
, CLSID
*pClassID
)
356 MediaCatMoniker
*This
= impl_from_IMoniker(iface
);
358 FIXME("(%p)->(%p): stub\n", This
, pClassID
);
360 if (pClassID
== NULL
)
366 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_IsDirty(IMoniker
*iface
)
368 FIXME("(%p)->(): stub\n", iface
);
373 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_Load(IMoniker
*iface
, IStream
*pStm
)
375 FIXME("(%p)->(%p): stub\n", iface
, pStm
);
380 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_Save(IMoniker
*iface
, IStream
*pStm
, BOOL fClearDirty
)
382 FIXME("(%p)->(%p, %s): stub\n", iface
, pStm
, fClearDirty
? "true" : "false");
384 return STG_E_CANTSAVE
;
387 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_GetSizeMax(IMoniker
*iface
, ULARGE_INTEGER
*pcbSize
)
389 FIXME("(%p)->(%p): stub\n", iface
, pcbSize
);
391 ZeroMemory(pcbSize
, sizeof(*pcbSize
));
396 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_BindToObject(IMoniker
*iface
, IBindCtx
*pbc
,
397 IMoniker
*pmkToLeft
, REFIID riidResult
, void **ppvResult
)
399 MediaCatMoniker
*This
= impl_from_IMoniker(iface
);
400 IUnknown
* pObj
= NULL
;
401 IPropertyBag
* pProp
= NULL
;
404 HRESULT res
= E_FAIL
;
406 TRACE("(%p)->(%p, %p, %s, %p)\n", This
, pbc
, pmkToLeft
, debugstr_guid(riidResult
), ppvResult
);
413 /* first activation of this class */
415 res
=IMoniker_BindToStorage(iface
, NULL
, NULL
, &IID_IPropertyBag
, &pvptr
);
419 V_VT(&var
) = VT_LPWSTR
;
420 res
= IPropertyBag_Read(pProp
, clsid_keyname
, &var
, NULL
);
424 res
= CLSIDFromString(V_BSTR(&var
), &clsID
);
425 CoTaskMemFree(V_BSTR(&var
));
429 res
=CoCreateInstance(&clsID
,NULL
,CLSCTX_ALL
,&IID_IUnknown
,&pvptr
);
436 /* get the requested interface from the loaded class */
441 res2
= IUnknown_QueryInterface(pObj
, &IID_IPersistPropertyBag
, &ppv
);
442 if (SUCCEEDED(res2
)) {
443 res
= IPersistPropertyBag_Load((IPersistPropertyBag
*) ppv
, pProp
, NULL
);
444 IPersistPropertyBag_Release((IPersistPropertyBag
*) ppv
);
448 res
= IUnknown_QueryInterface(pObj
,riidResult
,ppvResult
);
449 IUnknown_Release(pObj
);
454 IPropertyBag_Release(pProp
);
457 TRACE("<- 0x%x\n", res
);
462 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_BindToStorage(IMoniker
*iface
, IBindCtx
*pbc
,
463 IMoniker
*pmkToLeft
, REFIID riid
, void **ppvObj
)
465 MediaCatMoniker
*This
= impl_from_IMoniker(iface
);
467 TRACE("(%p)->(%p, %p, %s, %p)\n", This
, pbc
, pmkToLeft
, debugstr_guid(riid
), ppvObj
);
472 return MK_E_NOSTORAGE
;
476 static DWORD reported
;
479 FIXME("ignoring IBindCtx %p\n", pbc
);
484 if (IsEqualGUID(riid
, &IID_IPropertyBag
))
487 DuplicateHandle(GetCurrentProcess(), This
->hkey
, GetCurrentProcess(), &hkey
, 0, 0, DUPLICATE_SAME_ACCESS
);
488 return DEVENUM_IPropertyBag_Construct(hkey
, (IPropertyBag
**)ppvObj
);
491 return MK_E_NOSTORAGE
;
494 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_Reduce(IMoniker
*iface
, IBindCtx
*pbc
,
495 DWORD dwReduceHowFar
, IMoniker
**ppmkToLeft
, IMoniker
**ppmkReduced
)
497 TRACE("(%p)->(%p, %d, %p, %p)\n", iface
, pbc
, dwReduceHowFar
, ppmkToLeft
, ppmkReduced
);
501 *ppmkReduced
= iface
;
503 return MK_S_REDUCED_TO_SELF
;
506 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_ComposeWith(IMoniker
*iface
, IMoniker
*pmkRight
,
507 BOOL fOnlyIfNotGeneric
, IMoniker
**ppmkComposite
)
509 FIXME("(%p)->(%p, %s, %p): stub\n", iface
, pmkRight
, fOnlyIfNotGeneric
? "true" : "false", ppmkComposite
);
511 /* FIXME: use CreateGenericComposite? */
512 *ppmkComposite
= NULL
;
517 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_Enum(IMoniker
*iface
, BOOL fForward
,
518 IEnumMoniker
**ppenumMoniker
)
520 FIXME("(%p)->(%s, %p): stub\n", iface
, fForward
? "true" : "false", ppenumMoniker
);
522 *ppenumMoniker
= NULL
;
527 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_IsEqual(IMoniker
*iface
, IMoniker
*pmkOtherMoniker
)
529 FIXME("(%p)->(%p): stub\n", iface
, pmkOtherMoniker
);
534 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_Hash(IMoniker
*iface
, DWORD
*pdwHash
)
536 TRACE("(%p)->(%p)\n", iface
, pdwHash
);
543 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_IsRunning(IMoniker
*iface
, IBindCtx
*pbc
,
544 IMoniker
*pmkToLeft
, IMoniker
*pmkNewlyRunning
)
546 FIXME("(%p)->(%p, %p, %p): stub\n", iface
, pbc
, pmkToLeft
, pmkNewlyRunning
);
551 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_GetTimeOfLastChange(IMoniker
*iface
, IBindCtx
*pbc
,
552 IMoniker
*pmkToLeft
, FILETIME
*pFileTime
)
554 TRACE("(%p)->(%p, %p, %p)\n", iface
, pbc
, pmkToLeft
, pFileTime
);
556 pFileTime
->dwLowDateTime
= 0xFFFFFFFF;
557 pFileTime
->dwHighDateTime
= 0x7FFFFFFF;
559 return MK_E_UNAVAILABLE
;
562 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_Inverse(IMoniker
*iface
, IMoniker
**ppmk
)
564 TRACE("(%p)->(%p)\n", iface
, ppmk
);
568 return MK_E_NOINVERSE
;
571 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_CommonPrefixWith(IMoniker
*iface
,
572 IMoniker
*pmkOtherMoniker
, IMoniker
**ppmkPrefix
)
574 TRACE("(%p)->(%p, %p)\n", iface
, pmkOtherMoniker
, ppmkPrefix
);
578 return MK_E_NOPREFIX
;
581 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_RelativePathTo(IMoniker
*iface
, IMoniker
*pmkOther
,
582 IMoniker
**ppmkRelPath
)
584 TRACE("(%p)->(%p, %p)\n", iface
, pmkOther
, ppmkRelPath
);
586 *ppmkRelPath
= pmkOther
;
591 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_GetDisplayName(IMoniker
*iface
, IBindCtx
*pbc
,
592 IMoniker
*pmkToLeft
, LPOLESTR
*ppszDisplayName
)
594 MediaCatMoniker
*This
= impl_from_IMoniker(iface
);
595 WCHAR wszBuffer
[MAX_PATH
];
596 static const WCHAR wszFriendlyName
[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
597 LONG received
= sizeof(wszFriendlyName
);
599 TRACE("(%p)->(%p, %p, %p)\n", iface
, pbc
, pmkToLeft
, ppszDisplayName
);
601 *ppszDisplayName
= NULL
;
603 /* FIXME: should this be the weird stuff we have to parse in IParseDisplayName? */
604 if (RegQueryValueW(This
->hkey
, wszFriendlyName
, wszBuffer
, &received
) == ERROR_SUCCESS
)
606 *ppszDisplayName
= CoTaskMemAlloc(received
);
607 strcpyW(*ppszDisplayName
, wszBuffer
);
614 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_ParseDisplayName(IMoniker
*iface
, IBindCtx
*pbc
,
615 IMoniker
*pmkToLeft
, LPOLESTR pszDisplayName
, ULONG
*pchEaten
, IMoniker
**ppmkOut
)
617 FIXME("(%p)->(%p, %p, %s, %p, %p)\n", iface
, pbc
, pmkToLeft
, debugstr_w(pszDisplayName
), pchEaten
, ppmkOut
);
625 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_IsSystemMoniker(IMoniker
*iface
, DWORD
*pdwMksys
)
627 TRACE("(%p)->(%p)\n", iface
, pdwMksys
);
632 static const IMonikerVtbl IMoniker_Vtbl
=
634 DEVENUM_IMediaCatMoniker_QueryInterface
,
635 DEVENUM_IMediaCatMoniker_AddRef
,
636 DEVENUM_IMediaCatMoniker_Release
,
637 DEVENUM_IMediaCatMoniker_GetClassID
,
638 DEVENUM_IMediaCatMoniker_IsDirty
,
639 DEVENUM_IMediaCatMoniker_Load
,
640 DEVENUM_IMediaCatMoniker_Save
,
641 DEVENUM_IMediaCatMoniker_GetSizeMax
,
642 DEVENUM_IMediaCatMoniker_BindToObject
,
643 DEVENUM_IMediaCatMoniker_BindToStorage
,
644 DEVENUM_IMediaCatMoniker_Reduce
,
645 DEVENUM_IMediaCatMoniker_ComposeWith
,
646 DEVENUM_IMediaCatMoniker_Enum
,
647 DEVENUM_IMediaCatMoniker_IsEqual
,
648 DEVENUM_IMediaCatMoniker_Hash
,
649 DEVENUM_IMediaCatMoniker_IsRunning
,
650 DEVENUM_IMediaCatMoniker_GetTimeOfLastChange
,
651 DEVENUM_IMediaCatMoniker_Inverse
,
652 DEVENUM_IMediaCatMoniker_CommonPrefixWith
,
653 DEVENUM_IMediaCatMoniker_RelativePathTo
,
654 DEVENUM_IMediaCatMoniker_GetDisplayName
,
655 DEVENUM_IMediaCatMoniker_ParseDisplayName
,
656 DEVENUM_IMediaCatMoniker_IsSystemMoniker
659 MediaCatMoniker
* DEVENUM_IMediaCatMoniker_Construct(void)
661 MediaCatMoniker
* pMoniker
= NULL
;
662 pMoniker
= CoTaskMemAlloc(sizeof(MediaCatMoniker
));
666 pMoniker
->IMoniker_iface
.lpVtbl
= &IMoniker_Vtbl
;
668 pMoniker
->hkey
= NULL
;
670 DEVENUM_IMediaCatMoniker_AddRef(&pMoniker
->IMoniker_iface
);
672 DEVENUM_LockModule();
677 static inline EnumMonikerImpl
*impl_from_IEnumMoniker(IEnumMoniker
*iface
)
679 return CONTAINING_RECORD(iface
, EnumMonikerImpl
, IEnumMoniker_iface
);
682 static HRESULT WINAPI
DEVENUM_IEnumMoniker_QueryInterface(IEnumMoniker
*iface
, REFIID riid
,
685 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), ppv
);
690 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
691 IsEqualGUID(riid
, &IID_IEnumMoniker
))
694 IEnumMoniker_AddRef(iface
);
698 FIXME("- no interface IID: %s\n", debugstr_guid(riid
));
700 return E_NOINTERFACE
;
703 static ULONG WINAPI
DEVENUM_IEnumMoniker_AddRef(IEnumMoniker
*iface
)
705 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(iface
);
706 ULONG ref
= InterlockedIncrement(&This
->ref
);
708 TRACE("(%p) ref=%d\n", This
, ref
);
713 static ULONG WINAPI
DEVENUM_IEnumMoniker_Release(IEnumMoniker
*iface
)
715 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(iface
);
716 ULONG ref
= InterlockedDecrement(&This
->ref
);
718 TRACE("(%p) ref=%d\n", This
, ref
);
722 if(This
->special_hkey
)
723 RegCloseKey(This
->special_hkey
);
724 RegCloseKey(This
->hkey
);
726 DEVENUM_UnlockModule();
732 static HRESULT WINAPI
DEVENUM_IEnumMoniker_Next(IEnumMoniker
*iface
, ULONG celt
, IMoniker
**rgelt
,
735 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(iface
);
736 WCHAR buffer
[MAX_PATH
+ 1];
739 MediaCatMoniker
* pMoniker
;
741 TRACE("(%p)->(%d, %p, %p)\n", iface
, celt
, rgelt
, pceltFetched
);
743 while (fetched
< celt
)
745 if(This
->index
+fetched
< This
->subkey_cnt
)
746 res
= RegEnumKeyW(This
->hkey
, This
->index
+fetched
, buffer
, sizeof(buffer
) / sizeof(WCHAR
));
747 else if(This
->special_hkey
)
748 res
= RegEnumKeyW(This
->special_hkey
, This
->index
+fetched
-This
->subkey_cnt
, buffer
, sizeof(buffer
) / sizeof(WCHAR
));
751 if (res
!= ERROR_SUCCESS
)
755 pMoniker
= DEVENUM_IMediaCatMoniker_Construct();
757 return E_OUTOFMEMORY
;
759 if (RegOpenKeyW(This
->index
+fetched
< This
->subkey_cnt
? This
->hkey
: This
->special_hkey
,
760 buffer
, &pMoniker
->hkey
) != ERROR_SUCCESS
)
762 IMoniker_Release(&pMoniker
->IMoniker_iface
);
765 rgelt
[fetched
] = &pMoniker
->IMoniker_iface
;
769 This
->index
+= fetched
;
771 TRACE("-- fetched %d\n", fetched
);
774 *pceltFetched
= fetched
;
782 static HRESULT WINAPI
DEVENUM_IEnumMoniker_Skip(IEnumMoniker
*iface
, ULONG celt
)
784 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(iface
);
785 DWORD special_subkeys
= 0;
787 TRACE("(%p)->(%d)\n", iface
, celt
);
789 /* Before incrementing, check if there are any more values to run through.
790 Some programs use the Skip() function to get the number of devices */
791 if(This
->special_hkey
)
792 RegQueryInfoKeyW(This
->special_hkey
, NULL
, NULL
, NULL
, &special_subkeys
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
);
794 if((This
->index
+ celt
) >= This
->subkey_cnt
+ special_subkeys
)
804 static HRESULT WINAPI
DEVENUM_IEnumMoniker_Reset(IEnumMoniker
*iface
)
806 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(iface
);
808 TRACE("(%p)->()\n", iface
);
815 static HRESULT WINAPI
DEVENUM_IEnumMoniker_Clone(IEnumMoniker
*iface
, IEnumMoniker
**ppenum
)
817 FIXME("(%p)->(%p): stub\n", iface
, ppenum
);
822 /**********************************************************************
825 static const IEnumMonikerVtbl IEnumMoniker_Vtbl
=
827 DEVENUM_IEnumMoniker_QueryInterface
,
828 DEVENUM_IEnumMoniker_AddRef
,
829 DEVENUM_IEnumMoniker_Release
,
830 DEVENUM_IEnumMoniker_Next
,
831 DEVENUM_IEnumMoniker_Skip
,
832 DEVENUM_IEnumMoniker_Reset
,
833 DEVENUM_IEnumMoniker_Clone
836 HRESULT
DEVENUM_IEnumMoniker_Construct(HKEY hkey
, HKEY special_hkey
, IEnumMoniker
** ppEnumMoniker
)
838 EnumMonikerImpl
* pEnumMoniker
= CoTaskMemAlloc(sizeof(EnumMonikerImpl
));
840 return E_OUTOFMEMORY
;
842 pEnumMoniker
->IEnumMoniker_iface
.lpVtbl
= &IEnumMoniker_Vtbl
;
843 pEnumMoniker
->ref
= 1;
844 pEnumMoniker
->index
= 0;
845 pEnumMoniker
->hkey
= hkey
;
846 pEnumMoniker
->special_hkey
= special_hkey
;
848 *ppEnumMoniker
= &pEnumMoniker
->IEnumMoniker_iface
;
850 if(RegQueryInfoKeyW(pEnumMoniker
->hkey
, NULL
, NULL
, NULL
, &pEnumMoniker
->subkey_cnt
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
) != ERROR_SUCCESS
)
851 pEnumMoniker
->subkey_cnt
= 0;
854 DEVENUM_LockModule();