Поделиться через


IIterator<T>::get_HasCurrent method

Gets a value that indicates whether there is a current item or the iterator is at the end of the collection.

Syntax

HRESULT get_HasCurrent(
  [out, retval] boolean *hasCurrent
);

Parameters

  • hasCurrent [out, retval]
    Type: boolean*

    TRUE if the iterator refers to a valid item that is in the collection; otherwise, FALSE if the iterator is at the end of 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.

 

Remarks

Use the get_HasCurrent method to check for a valid iterator before calling the get_Current method.

Examples

The following code example demonstrates how to use the get_HasCurrent 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