mercredi 29 novembre 2017

SHOpenFolderAndSelectItems() with arrays

I can successfully use SHOpenFolderandSelectItems() in trivial cases. Code looks similar to this:

ITEMIDLIST *idl = ILCreateFromPath(L"C:\\testing\\example.txt");
SHOpenFolderAndSelectItems(idl, 0, 0, 0);
ILFree(idl);

Now what I'd like to do is open up a folder and select multiple files within it. But I'm confused as to what SHOpenFolderAndSelectItems() is expecting. Simplified, this is what I'm trying:

ITEMIDLIST *folder = ILCreateFromPath(L"C:\\testing\\");
std::vector<ITEMIDLLIST*> v;
v.push_back( ILCreateFromPath(L"C:\\testing\\test1.txt");
v.push_back( ILCreateFromPath(L"C:\\testing\\test2.txt");
v.push_back( ILCreateFromPath(L"C:\\testing\\test3.txt");

SHOpenFolderAndSelectItems(folder, v.size(), v.data(), 0);

for (auto idl : v)
{
    ILFree(idl);
}
ILFree(folder);

This results in:

error C2664: 'HRESULT SHOpenFolderAndSelectItems(LPCITEMIDLIST,UINT,LPCITEMIDLIST *,DWORD)': cannot convert argument 3 from '_ITEMIDLIST **' to 'LPCITEMIDLIST *'

What is a decent way to create the array of items?

Aucun commentaire:

Enregistrer un commentaire