Programmatically select multiple files in windows explorer

Question :

Programmatically select multiple files in windows explorer,

Answer :

I can display and select a single file in windows explorer like this:

explorer.exe /select, "c:pathtofile.txt"  

However, I can’t work out how to select more than one file. None of the permutations of select I’ve tried work.

Note: I looked at these pages for docs, neither helped.


This should be possible with the shell function SHOpenFolderAndSelectItems


Here is some sample code showing how to use the function in C/C++, without error checking:

//Directory to open  ITEMIDLIST *dir = ILCreateFromPath(_T("C:\"));    //Items in directory to select  ITEMIDLIST *item1 = ILCreateFromPath(_T("C:\Program Files\"));  ITEMIDLIST *item2 = ILCreateFromPath(_T("C:\Windows\"));  const ITEMIDLIST* selection[] = {item1,item2};  UINT count = sizeof(selection) / sizeof(ITEMIDLIST);    //Perform selection  SHOpenFolderAndSelectItems(dir, count, selection, 0);    //Free resources  ILFree(dir);  ILFree(item1);  ILFree(item2);  

That’s the answer Programmatically select multiple files in windows explorer, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.

Read More  Is it possible to slipstream the Visual Studio 2008 SP1 install?

Disclaimer :

The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you