Windows Dev Center

Collapse the table of content
Expand the table of content
Expand Minimize
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

IIterable<T>::First method

Returns an iterator that iterates over the items in the collection.

Syntax


HRESULT First(
  [out, retval] IIterator<T> **first
);

Parameters

first [out, retval]

Type: IIterator<T>**

The iterator.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Examples

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

IIterable<T>

 

 

Community Additions

Show:
© 2015 Microsoft