IIterator<T>::get_Current method

Gets the current item in the collection.

Syntax

HRESULT get_Current(
  [out, retval] T *current
);

Parameters

  • current [out, retval]
    Type: T*

    The current item in the collection.

Return value

Type: HRESULT

This method can return one of these values.

Return code Description
S_OK

The current item was retrieved successfully.

E_CHANGED_STATE

The iterator has been invalidated.

E_BOUNDS

The iterator refers to an item that is not valid or is at the end of the collection.

 

Remarks

Check for a valid current item by calling the get_HasCurrent method.

Examples

The following code example demonstrates how to use the get_Current method.

comptr<Folder> spFolder;
hr = GetKnownFolder(FOLDERID_MusicFolder, &spFolder);
//...
comptr<IVectorView<IShellItem2>> spItems;
hr = pFolder->GetItems(&spItems);
//...
comptr<IIterator<IShellItem2>> spIter;
hr = spItems->First(&spIter);
//...
bool hasCurrent;
for (hr = spIter->get_HasCurrent(&hasCurrent); 
     SUCCEEDED(hr) && hasCurrent; 
     hr = spIter->MoveNext(&hasCurrent))
{
    comptr<IShellItem2> spAnItem;
    hr = spIter->get_Current(&spAnItem)
    //...
}

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Header

Windows.Foundation.Collections.h

See also

IIterator<T>

IIterable