Search code examples
winapicom

Get Index from ITEMIDLIST?


Given an ITEMID_CHILD (ITEMIDLIST) obtained from an IEnumIDList::Next() which is an enumeration of IFolderView::Items(), how do you convert the ITEMIDLIST to the index which would be needed in something like IFolderView::SelectItem()?

P.S. I know IFolderView::SelectAndPositionItems() exists, but this question is specific to obtaining the index (I couldn't find where an ::IndexOf() exists)

TIA!!


Solution

  • There is no direct way exposed by IFolderView to get the index of a given child ITEMIDLIST. You have to remember the index manually while enumerating the folder's items with IEnumIDList. Or, you can loop through the items using IFolderView::Item() until you find an index that returns a matching ITEMIDLIST.