Home COM GDI+ WebBrowser Data Access

IEnumMoniker Interface

 

IID_IEnumMoniker

{00000102-0000-0000-C000-000000000046}

 

 

The IEnumMoniker interface is used to enumerate the components of a moniker or to enumerate the monikers in a table of monikers.

 

Call the methods of the IEnumMoniker interface if you need to enumerate the components of a composite moniker, or to enumerate the monikers in a table.

 

OLE defines two interfaces that supply an IEnumMoniker interface pointer:

  • The IMoniker::Enum method gets a pointer to an IEnumMoniker implementation that can enumerate forwards or backwards through the components of the moniker. For a description of how two of the system-supplied types of monikers enumerate their components, see IMonikerFile Moniker Implementation and IMoniker – Generic Composite Moniker Implementation.
     

  • The IRunningObjectTable::EnumRunning method returns a pointer to an IEnumMoniker implementation that can enumerate the monikers registered in a Running Object Table.
     

 

Methods in VTable order

IUnknown Methods

Description

QueryInterface

Returns pointers to supported interfaces.

AddRef

Increments reference count.

Release

Decrements reference count.

IEnumMoniker Methods

Description

Next

Gets the next items in the enumeration sequence.

Skip

Attempts to skip over the next celt elements in the enumeration sequence.

Reset

Resets the enumeration sequence to the beginning.

Clone

Creates a copy of the current state of enumeration.

 

Next

 

FUNCTION IEnumMoniker_Next ( _

  BYVAL pthis AS DWORD PTR _

, BYVAL celt AS DWORD _

, BYVAL rgelt AS DWORD _

, BYREF pceltFetched AS DWORD _

  ) AS LONG
 

  LOCAL HRESULT AS LONG
  CALL DWORD @@pthis[3] USING IEnumMoniker_Next (pthis, celt, rgelt, pceltFetched) TO HRESULT
  FUNCTION = HRESULT
 

END FUNCTION

 

 

Skip

 

FUNCTION IEnumMoniker_Skip ( _

  BYVAL pthis AS DWORD PTR _

, BYVAL celt AS DWORD _

  ) AS LONG
 

  LOCAL HRESULT AS LONG
  CALL DWORD @@pthis[4] USING IEnumMoniker_Skip (pthis, celt) TO HRESULT
  FUNCTION = HRESULT
 

END FUNCTION

 

 

Reset

 

FUNCTION IEnumMoniker_Reset ( _

  BYVAL pthis AS DWORD PTR _

  ) AS LONG
 

  LOCAL HRESULT AS LONG
  CALL DWORD @@pthis[5] USING IEnumMoniker_Reset (pthis) TO HRESULT
  FUNCTION = HRESULT
 

END FUNCTION

 

 

Clone

 

FUNCTION IEnumMoniker_Clone ( _

  BYVAL pthis AS DWORD PTR _

, BYVAL ppenum AS DWORD _

  ) AS LONG
 

  LOCAL HRESULT AS LONG
  CALL DWORD @@pthis[6] USING IEnumMoniker_Clone (pthis, ppenum) TO HRESULT
  FUNCTION = HRESULT
 

END FUNCTION

 

 

Example

 

The following example shows the display names of all the objects currently registered in the Running Object Table (ROT)

 

#COMPILE EXE
#DIM ALL
#INCLUDE
"Win32Api.inc"
 

FUNCTION PBMAIN

   LOCAL
hr AS LONG
   LOCAL
ppbc AS DWORD
   LOCAL
pprot AS DWORD
   LOCAL
ppenumMoniker AS DWORD
   LOCAL
ppMoniker AS DWORD
   LOCAL
pceltFetched AS DWORD
   LOCAL
strDisplayName AS STRING

   ' Get a pointer to the Running Object Table (ROT)
   hr = CreateBindCtx(0, ppbc)
   IF
hr <> %S_OK OR ppbc = %NULL THEN GOTO Terminate
   hr = IBindCtx_GetRunningObjectTable(ppbc, pprot)
  
IUnknown_Release ppbc
   IF
hr <> %S_OK OR pprot = %NULL THEN GOTO Terminate
 

   ' Get a pointer to the moniker enumerator
   hr = IRunningObjectTable_EnumRunning(pprot, ppenumMoniker)
   IF
hr <> %S_OK OR ppenumMoniker = %NULL THEN GOTO Terminate

   ' Enumerate the monikers and retrieve the display name
   ppMoniker = 0
   DO
      hr = IEnumMoniker_Next(ppenumMoniker, 1, VARPTR(ppMoniker), pceltFetched)
      IF hr <> %S_OK OR ppMoniker = 0 OR pceltFetched = 0 THEN EXIT DO
      hr = IMoniker_GetDisplayName(ppMoniker, ppbc, %NULL, strDisplayName)
      IF ppMoniker THEN IUnknown_Release ppMoniker
      IF hr <> %S_OK THEN EXIT DO
      MSGBOX strDisplayName
   LOOP

   ' Release the enumerator
   IF ppenumMoniker THEN IUnknown_Release ppenumMoniker

Terminate:

   ' Release the Running Object Table
   IF pprot THEN IUnknown_Release pprot


END FUNCTION

 

 

Page last updated on Friday, 17 March 2006 17:21:58 +0100