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"
32 IEnumMoniker IEnumMoniker_iface
;
40 IPropertyBag IPropertyBag_iface
;
46 static inline RegPropBagImpl
*impl_from_IPropertyBag(IPropertyBag
*iface
)
48 return CONTAINING_RECORD(iface
, RegPropBagImpl
, IPropertyBag_iface
);
51 static HRESULT WINAPI
DEVENUM_IPropertyBag_QueryInterface(
56 RegPropBagImpl
*This
= impl_from_IPropertyBag(iface
);
58 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), ppvObj
);
60 if (This
== NULL
|| ppvObj
== NULL
) return E_POINTER
;
62 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
63 IsEqualGUID(riid
, &IID_IPropertyBag
))
66 IPropertyBag_AddRef(iface
);
70 FIXME("- no interface IID: %s\n", debugstr_guid(riid
));
74 /**********************************************************************
75 * DEVENUM_IPropertyBag_AddRef (also IUnknown)
77 static ULONG WINAPI
DEVENUM_IPropertyBag_AddRef(LPPROPERTYBAG iface
)
79 RegPropBagImpl
*This
= impl_from_IPropertyBag(iface
);
81 TRACE("(%p)->() AddRef from %d\n", iface
, This
->ref
);
83 return InterlockedIncrement(&This
->ref
);
86 /**********************************************************************
87 * DEVENUM_IPropertyBag_Release (also IUnknown)
89 static ULONG WINAPI
DEVENUM_IPropertyBag_Release(LPPROPERTYBAG iface
)
91 RegPropBagImpl
*This
= impl_from_IPropertyBag(iface
);
94 TRACE("(%p)->() ReleaseThis->ref from %d\n", iface
, This
->ref
);
96 ref
= InterlockedDecrement(&This
->ref
);
98 RegCloseKey(This
->hkey
);
100 DEVENUM_UnlockModule();
105 static HRESULT WINAPI
DEVENUM_IPropertyBag_Read(
107 LPCOLESTR pszPropName
,
109 IErrorLog
* pErrorLog
)
114 RegPropBagImpl
*This
= impl_from_IPropertyBag(iface
);
118 TRACE("(%p)->(%s, %p, %p)\n", This
, debugstr_w(pszPropName
), pVar
, pErrorLog
);
120 if (!pszPropName
|| !pVar
)
123 reswin32
= RegQueryValueExW(This
->hkey
, pszPropName
, NULL
, NULL
, NULL
, &received
);
124 res
= HRESULT_FROM_WIN32(reswin32
);
128 pData
= HeapAlloc(GetProcessHeap(), 0, received
);
130 /* work around a GCC bug that occurs here unless we use the reswin32 variable as well */
131 reswin32
= RegQueryValueExW(This
->hkey
, pszPropName
, NULL
, &type
, pData
, &received
);
132 res
= HRESULT_FROM_WIN32(reswin32
);
137 res
= E_INVALIDARG
; /* assume we cannot coerce into right type */
139 TRACE("Read %d bytes (%s)\n", received
, type
== REG_SZ
? debugstr_w(pData
) : "binary data");
147 V_UNION(pVar
, bstrVal
) = CoTaskMemAlloc(received
);
148 memcpy(V_UNION(pVar
, bstrVal
), pData
, received
);
152 V_VT(pVar
) = VT_BSTR
;
155 V_UNION(pVar
, bstrVal
) = SysAllocStringLen(pData
, received
/sizeof(WCHAR
) - 1);
161 TRACE("REG_DWORD: %x\n", *(DWORD
*)pData
);
169 V_UNION(pVar
, ulVal
) = *(DWORD
*)pData
;
176 SAFEARRAYBOUND bound
;
177 void * pArrayElements
;
179 bound
.cElements
= received
;
180 TRACE("REG_BINARY: len = %d\n", received
);
184 V_VT(pVar
) = VT_ARRAY
| VT_UI1
;
186 case VT_ARRAY
| VT_UI1
:
187 if (!(V_UNION(pVar
, parray
) = SafeArrayCreate(VT_UI1
, 1, &bound
)))
194 if (res
== E_INVALIDARG
)
197 res
= SafeArrayAccessData(V_UNION(pVar
, parray
), &pArrayElements
);
201 CopyMemory(pArrayElements
, pData
, received
);
202 res
= SafeArrayUnaccessData(V_UNION(pVar
, parray
));
206 if (res
== E_INVALIDARG
)
207 FIXME("Variant type %x not supported for regtype %x\n", V_VT(pVar
), type
);
210 HeapFree(GetProcessHeap(), 0, pData
);
212 TRACE("<- %x\n", res
);
216 static HRESULT WINAPI
DEVENUM_IPropertyBag_Write(
218 LPCOLESTR pszPropName
,
221 RegPropBagImpl
*This
= impl_from_IPropertyBag(iface
);
222 LPVOID lpData
= NULL
;
227 TRACE("(%p)->(%s, %p)\n", This
, debugstr_w(pszPropName
), pVar
);
233 TRACE("writing %s\n", debugstr_w(V_UNION(pVar
, bstrVal
)));
234 lpData
= V_UNION(pVar
, bstrVal
);
236 cbData
= (lstrlenW(V_UNION(pVar
, bstrVal
)) + 1) * sizeof(WCHAR
);
240 TRACE("writing %u\n", V_UNION(pVar
, ulVal
));
241 lpData
= &V_UNION(pVar
, ulVal
);
243 cbData
= sizeof(DWORD
);
245 case VT_ARRAY
| VT_UI1
:
250 res
= SafeArrayGetLBound(V_UNION(pVar
, parray
), 1, &lLbound
);
251 res
= SafeArrayGetUBound(V_UNION(pVar
, parray
), 1, &lUbound
);
252 cbData
= (lUbound
- lLbound
+ 1) /* * sizeof(BYTE)*/;
253 TRACE("cbData: %d\n", cbData
);
254 res
= SafeArrayAccessData(V_UNION(pVar
, parray
), &lpData
);
258 FIXME("Variant type %d not handled\n", V_VT(pVar
));
262 if (RegSetValueExW(This
->hkey
,
264 dwType
, lpData
, cbData
) != ERROR_SUCCESS
)
267 if (V_VT(pVar
) & VT_ARRAY
)
268 res
= SafeArrayUnaccessData(V_UNION(pVar
, parray
));
273 static const IPropertyBagVtbl IPropertyBag_Vtbl
=
275 DEVENUM_IPropertyBag_QueryInterface
,
276 DEVENUM_IPropertyBag_AddRef
,
277 DEVENUM_IPropertyBag_Release
,
278 DEVENUM_IPropertyBag_Read
,
279 DEVENUM_IPropertyBag_Write
282 static HRESULT
DEVENUM_IPropertyBag_Construct(HANDLE hkey
, IPropertyBag
**ppBag
)
284 RegPropBagImpl
* rpb
= CoTaskMemAlloc(sizeof(RegPropBagImpl
));
286 return E_OUTOFMEMORY
;
287 rpb
->IPropertyBag_iface
.lpVtbl
= &IPropertyBag_Vtbl
;
290 *ppBag
= &rpb
->IPropertyBag_iface
;
291 DEVENUM_LockModule();
296 static inline MediaCatMoniker
*impl_from_IMoniker(IMoniker
*iface
)
298 return CONTAINING_RECORD(iface
, MediaCatMoniker
, IMoniker_iface
);
301 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_QueryInterface(IMoniker
*iface
, REFIID riid
,
304 TRACE("\n\tIID:\t%s\n",debugstr_guid(riid
));
309 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
310 IsEqualGUID(riid
, &IID_IPersist
) ||
311 IsEqualGUID(riid
, &IID_IPersistStream
) ||
312 IsEqualGUID(riid
, &IID_IMoniker
))
315 IMoniker_AddRef(iface
);
319 FIXME("- no interface IID: %s\n", debugstr_guid(riid
));
321 return E_NOINTERFACE
;
324 static ULONG WINAPI
DEVENUM_IMediaCatMoniker_AddRef(IMoniker
*iface
)
326 MediaCatMoniker
*This
= impl_from_IMoniker(iface
);
327 ULONG ref
= InterlockedIncrement(&This
->ref
);
329 TRACE("(%p) ref=%d\n", This
, ref
);
334 static ULONG WINAPI
DEVENUM_IMediaCatMoniker_Release(IMoniker
*iface
)
336 MediaCatMoniker
*This
= impl_from_IMoniker(iface
);
337 ULONG ref
= InterlockedDecrement(&This
->ref
);
339 TRACE("(%p) ref=%d\n", This
, ref
);
342 RegCloseKey(This
->hkey
);
344 DEVENUM_UnlockModule();
349 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_GetClassID(IMoniker
*iface
, CLSID
*pClassID
)
351 MediaCatMoniker
*This
= impl_from_IMoniker(iface
);
353 FIXME("(%p)->(%p): stub\n", This
, pClassID
);
355 if (pClassID
== NULL
)
361 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_IsDirty(IMoniker
*iface
)
363 FIXME("(%p)->(): stub\n", iface
);
368 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_Load(IMoniker
*iface
, IStream
*pStm
)
370 FIXME("(%p)->(%p): stub\n", iface
, pStm
);
375 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_Save(IMoniker
*iface
, IStream
*pStm
, BOOL fClearDirty
)
377 FIXME("(%p)->(%p, %s): stub\n", iface
, pStm
, fClearDirty
? "true" : "false");
379 return STG_E_CANTSAVE
;
382 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_GetSizeMax(IMoniker
*iface
, ULARGE_INTEGER
*pcbSize
)
384 FIXME("(%p)->(%p): stub\n", iface
, pcbSize
);
386 ZeroMemory(pcbSize
, sizeof(*pcbSize
));
391 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_BindToObject(IMoniker
*iface
, IBindCtx
*pbc
,
392 IMoniker
*pmkToLeft
, REFIID riidResult
, void **ppvResult
)
394 MediaCatMoniker
*This
= impl_from_IMoniker(iface
);
395 IUnknown
* pObj
= NULL
;
396 IPropertyBag
* pProp
= NULL
;
399 HRESULT res
= E_FAIL
;
401 TRACE("(%p)->(%p, %p, %s, %p)\n", This
, pbc
, pmkToLeft
, debugstr_guid(riidResult
), ppvResult
);
408 /* first activation of this class */
410 res
=IMoniker_BindToStorage(iface
, NULL
, NULL
, &IID_IPropertyBag
, &pvptr
);
414 V_VT(&var
) = VT_LPWSTR
;
415 res
= IPropertyBag_Read(pProp
, clsid_keyname
, &var
, NULL
);
419 res
= CLSIDFromString(V_UNION(&var
,bstrVal
), &clsID
);
420 CoTaskMemFree(V_UNION(&var
, bstrVal
));
424 res
=CoCreateInstance(&clsID
,NULL
,CLSCTX_ALL
,&IID_IUnknown
,&pvptr
);
431 /* get the requested interface from the loaded class */
436 res2
= IUnknown_QueryInterface(pObj
, &IID_IPersistPropertyBag
, &ppv
);
437 if (SUCCEEDED(res2
)) {
438 res
= IPersistPropertyBag_Load((IPersistPropertyBag
*) ppv
, pProp
, NULL
);
439 IPersistPropertyBag_Release((IPersistPropertyBag
*) ppv
);
443 res
= IUnknown_QueryInterface(pObj
,riidResult
,ppvResult
);
444 IUnknown_Release(pObj
);
449 IPropertyBag_Release(pProp
);
452 TRACE("<- 0x%x\n", res
);
457 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_BindToStorage(IMoniker
*iface
, IBindCtx
*pbc
,
458 IMoniker
*pmkToLeft
, REFIID riid
, void **ppvObj
)
460 MediaCatMoniker
*This
= impl_from_IMoniker(iface
);
462 TRACE("(%p)->(%p, %p, %s, %p)\n", This
, pbc
, pmkToLeft
, debugstr_guid(riid
), ppvObj
);
467 return MK_E_NOSTORAGE
;
471 static DWORD reported
;
474 FIXME("ignoring IBindCtx %p\n", pbc
);
479 if (IsEqualGUID(riid
, &IID_IPropertyBag
))
482 DuplicateHandle(GetCurrentProcess(), This
->hkey
, GetCurrentProcess(), &hkey
, 0, 0, DUPLICATE_SAME_ACCESS
);
483 return DEVENUM_IPropertyBag_Construct(hkey
, (IPropertyBag
**)ppvObj
);
486 return MK_E_NOSTORAGE
;
489 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_Reduce(IMoniker
*iface
, IBindCtx
*pbc
,
490 DWORD dwReduceHowFar
, IMoniker
**ppmkToLeft
, IMoniker
**ppmkReduced
)
492 TRACE("(%p)->(%p, %d, %p, %p)\n", iface
, pbc
, dwReduceHowFar
, ppmkToLeft
, ppmkReduced
);
496 *ppmkReduced
= iface
;
498 return MK_S_REDUCED_TO_SELF
;
501 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_ComposeWith(IMoniker
*iface
, IMoniker
*pmkRight
,
502 BOOL fOnlyIfNotGeneric
, IMoniker
**ppmkComposite
)
504 FIXME("(%p)->(%p, %s, %p): stub\n", iface
, pmkRight
, fOnlyIfNotGeneric
? "true" : "false", ppmkComposite
);
506 /* FIXME: use CreateGenericComposite? */
507 *ppmkComposite
= NULL
;
512 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_Enum(IMoniker
*iface
, BOOL fForward
,
513 IEnumMoniker
**ppenumMoniker
)
515 FIXME("(%p)->(%s, %p): stub\n", iface
, fForward
? "true" : "false", ppenumMoniker
);
517 *ppenumMoniker
= NULL
;
522 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_IsEqual(IMoniker
*iface
, IMoniker
*pmkOtherMoniker
)
524 FIXME("(%p)->(%p): stub\n", iface
, pmkOtherMoniker
);
529 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_Hash(IMoniker
*iface
, DWORD
*pdwHash
)
531 TRACE("(%p)->(%p)\n", iface
, pdwHash
);
538 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_IsRunning(IMoniker
*iface
, IBindCtx
*pbc
,
539 IMoniker
*pmkToLeft
, IMoniker
*pmkNewlyRunning
)
541 FIXME("(%p)->(%p, %p, %p): stub\n", iface
, pbc
, pmkToLeft
, pmkNewlyRunning
);
546 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_GetTimeOfLastChange(IMoniker
*iface
, IBindCtx
*pbc
,
547 IMoniker
*pmkToLeft
, FILETIME
*pFileTime
)
549 TRACE("(%p)->(%p, %p, %p)\n", iface
, pbc
, pmkToLeft
, pFileTime
);
551 pFileTime
->dwLowDateTime
= 0xFFFFFFFF;
552 pFileTime
->dwHighDateTime
= 0x7FFFFFFF;
554 return MK_E_UNAVAILABLE
;
557 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_Inverse(IMoniker
*iface
, IMoniker
**ppmk
)
559 TRACE("(%p)->(%p)\n", iface
, ppmk
);
563 return MK_E_NOINVERSE
;
566 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_CommonPrefixWith(IMoniker
*iface
,
567 IMoniker
*pmkOtherMoniker
, IMoniker
**ppmkPrefix
)
569 TRACE("(%p)->(%p, %p)\n", iface
, pmkOtherMoniker
, ppmkPrefix
);
573 return MK_E_NOPREFIX
;
576 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_RelativePathTo(IMoniker
*iface
, IMoniker
*pmkOther
,
577 IMoniker
**ppmkRelPath
)
579 TRACE("(%p)->(%p, %p)\n", iface
, pmkOther
, ppmkRelPath
);
581 *ppmkRelPath
= pmkOther
;
586 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_GetDisplayName(IMoniker
*iface
, IBindCtx
*pbc
,
587 IMoniker
*pmkToLeft
, LPOLESTR
*ppszDisplayName
)
589 MediaCatMoniker
*This
= impl_from_IMoniker(iface
);
590 WCHAR wszBuffer
[MAX_PATH
];
591 static const WCHAR wszFriendlyName
[] = {'F','r','i','e','n','d','l','y','N','a','m','e',0};
592 LONG received
= sizeof(wszFriendlyName
);
594 TRACE("(%p)->(%p, %p, %p)\n", iface
, pbc
, pmkToLeft
, ppszDisplayName
);
596 *ppszDisplayName
= NULL
;
598 /* FIXME: should this be the weird stuff we have to parse in IParseDisplayName? */
599 if (RegQueryValueW(This
->hkey
, wszFriendlyName
, wszBuffer
, &received
) == ERROR_SUCCESS
)
601 *ppszDisplayName
= CoTaskMemAlloc(received
);
602 strcpyW(*ppszDisplayName
, wszBuffer
);
609 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_ParseDisplayName(IMoniker
*iface
, IBindCtx
*pbc
,
610 IMoniker
*pmkToLeft
, LPOLESTR pszDisplayName
, ULONG
*pchEaten
, IMoniker
**ppmkOut
)
612 FIXME("(%p)->(%p, %p, %s, %p, %p)\n", iface
, pbc
, pmkToLeft
, debugstr_w(pszDisplayName
), pchEaten
, ppmkOut
);
620 static HRESULT WINAPI
DEVENUM_IMediaCatMoniker_IsSystemMoniker(IMoniker
*iface
, DWORD
*pdwMksys
)
622 TRACE("(%p)->(%p)\n", iface
, pdwMksys
);
627 static const IMonikerVtbl IMoniker_Vtbl
=
629 DEVENUM_IMediaCatMoniker_QueryInterface
,
630 DEVENUM_IMediaCatMoniker_AddRef
,
631 DEVENUM_IMediaCatMoniker_Release
,
632 DEVENUM_IMediaCatMoniker_GetClassID
,
633 DEVENUM_IMediaCatMoniker_IsDirty
,
634 DEVENUM_IMediaCatMoniker_Load
,
635 DEVENUM_IMediaCatMoniker_Save
,
636 DEVENUM_IMediaCatMoniker_GetSizeMax
,
637 DEVENUM_IMediaCatMoniker_BindToObject
,
638 DEVENUM_IMediaCatMoniker_BindToStorage
,
639 DEVENUM_IMediaCatMoniker_Reduce
,
640 DEVENUM_IMediaCatMoniker_ComposeWith
,
641 DEVENUM_IMediaCatMoniker_Enum
,
642 DEVENUM_IMediaCatMoniker_IsEqual
,
643 DEVENUM_IMediaCatMoniker_Hash
,
644 DEVENUM_IMediaCatMoniker_IsRunning
,
645 DEVENUM_IMediaCatMoniker_GetTimeOfLastChange
,
646 DEVENUM_IMediaCatMoniker_Inverse
,
647 DEVENUM_IMediaCatMoniker_CommonPrefixWith
,
648 DEVENUM_IMediaCatMoniker_RelativePathTo
,
649 DEVENUM_IMediaCatMoniker_GetDisplayName
,
650 DEVENUM_IMediaCatMoniker_ParseDisplayName
,
651 DEVENUM_IMediaCatMoniker_IsSystemMoniker
654 MediaCatMoniker
* DEVENUM_IMediaCatMoniker_Construct(void)
656 MediaCatMoniker
* pMoniker
= NULL
;
657 pMoniker
= CoTaskMemAlloc(sizeof(MediaCatMoniker
));
661 pMoniker
->IMoniker_iface
.lpVtbl
= &IMoniker_Vtbl
;
663 pMoniker
->hkey
= NULL
;
665 DEVENUM_IMediaCatMoniker_AddRef(&pMoniker
->IMoniker_iface
);
667 DEVENUM_LockModule();
672 static inline EnumMonikerImpl
*impl_from_IEnumMoniker(IEnumMoniker
*iface
)
674 return CONTAINING_RECORD(iface
, EnumMonikerImpl
, IEnumMoniker_iface
);
677 static HRESULT WINAPI
DEVENUM_IEnumMoniker_QueryInterface(IEnumMoniker
*iface
, REFIID riid
,
680 TRACE("(%p)->(%s, %p)\n", iface
, debugstr_guid(riid
), ppv
);
685 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
686 IsEqualGUID(riid
, &IID_IEnumMoniker
))
689 IEnumMoniker_AddRef(iface
);
693 FIXME("- no interface IID: %s\n", debugstr_guid(riid
));
695 return E_NOINTERFACE
;
698 static ULONG WINAPI
DEVENUM_IEnumMoniker_AddRef(IEnumMoniker
*iface
)
700 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(iface
);
701 ULONG ref
= InterlockedIncrement(&This
->ref
);
703 TRACE("(%p) ref=%d\n", This
, ref
);
708 static ULONG WINAPI
DEVENUM_IEnumMoniker_Release(IEnumMoniker
*iface
)
710 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(iface
);
711 ULONG ref
= InterlockedDecrement(&This
->ref
);
713 TRACE("(%p) ref=%d\n", This
, ref
);
717 RegCloseKey(This
->hkey
);
719 DEVENUM_UnlockModule();
725 static HRESULT WINAPI
DEVENUM_IEnumMoniker_Next(IEnumMoniker
*iface
, ULONG celt
, IMoniker
**rgelt
,
728 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(iface
);
729 WCHAR buffer
[MAX_PATH
+ 1];
732 MediaCatMoniker
* pMoniker
;
734 TRACE("(%p)->(%d, %p, %p)\n", iface
, celt
, rgelt
, pceltFetched
);
736 while (fetched
< celt
)
738 res
= RegEnumKeyW(This
->hkey
, This
->index
, buffer
, sizeof(buffer
) / sizeof(WCHAR
));
739 if (res
!= ERROR_SUCCESS
)
743 pMoniker
= DEVENUM_IMediaCatMoniker_Construct();
745 return E_OUTOFMEMORY
;
747 if (RegOpenKeyW(This
->hkey
, buffer
, &pMoniker
->hkey
) != ERROR_SUCCESS
)
749 IMoniker_Release(&pMoniker
->IMoniker_iface
);
752 rgelt
[fetched
] = &pMoniker
->IMoniker_iface
;
756 This
->index
+= fetched
;
758 TRACE("-- fetched %d\n", fetched
);
761 *pceltFetched
= fetched
;
769 static HRESULT WINAPI
DEVENUM_IEnumMoniker_Skip(IEnumMoniker
*iface
, ULONG celt
)
771 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(iface
);
774 TRACE("(%p)->(%d)\n", iface
, celt
);
776 /* Before incrementing, check if there are any more values to run through.
777 Some programs use the Skip() function to get the number of devices */
778 if(RegQueryInfoKeyW(This
->hkey
, NULL
, NULL
, NULL
, &subKeys
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
, NULL
) != ERROR_SUCCESS
)
782 if((This
->index
+ celt
) >= subKeys
)
792 static HRESULT WINAPI
DEVENUM_IEnumMoniker_Reset(IEnumMoniker
*iface
)
794 EnumMonikerImpl
*This
= impl_from_IEnumMoniker(iface
);
796 TRACE("(%p)->()\n", iface
);
803 static HRESULT WINAPI
DEVENUM_IEnumMoniker_Clone(IEnumMoniker
*iface
, IEnumMoniker
**ppenum
)
805 FIXME("(%p)->(%p): stub\n", iface
, ppenum
);
810 /**********************************************************************
813 static const IEnumMonikerVtbl IEnumMoniker_Vtbl
=
815 DEVENUM_IEnumMoniker_QueryInterface
,
816 DEVENUM_IEnumMoniker_AddRef
,
817 DEVENUM_IEnumMoniker_Release
,
818 DEVENUM_IEnumMoniker_Next
,
819 DEVENUM_IEnumMoniker_Skip
,
820 DEVENUM_IEnumMoniker_Reset
,
821 DEVENUM_IEnumMoniker_Clone
824 HRESULT
DEVENUM_IEnumMoniker_Construct(HKEY hkey
, IEnumMoniker
** ppEnumMoniker
)
826 EnumMonikerImpl
* pEnumMoniker
= CoTaskMemAlloc(sizeof(EnumMonikerImpl
));
828 return E_OUTOFMEMORY
;
830 pEnumMoniker
->IEnumMoniker_iface
.lpVtbl
= &IEnumMoniker_Vtbl
;
831 pEnumMoniker
->ref
= 1;
832 pEnumMoniker
->index
= 0;
833 pEnumMoniker
->hkey
= hkey
;
835 *ppEnumMoniker
= &pEnumMoniker
->IEnumMoniker_iface
;
837 DEVENUM_LockModule();