Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Disclaimer: I think <a href="https://stackoverflow.com/questions/1073353/c-how-to-open-windows-explorer-windows-with-a-number-of-files-selected/3578581#3578581">VirtualBlackFox's answer</a> is better than mine although it has less votes at present, so scroll down and read that one first :)</strong></p> <p>Easy method (might not work on all platforms):</p> <pre><code>Process.Start(String, String) </code></pre> <p>First argument is the application, second argument is the command line parameters of the application..</p> <p>So for example:</p> <pre><code>Process.Start("explorer.exe", "/select,Z:\Music\Thursday Blues\01. I wish it was friday.mp3") Process.Start("explorer.exe", "/select,Z:\Music\Counting Sheep\01. Sheep #1.mp3 /select,Z:\Music\Counting Sheep\02. Sheep #2.mp3") </code></pre> <p>(I think you might need escaped quotes around the file paths if they have spaces).</p> <p>more info: <a href="http://msdn.microsoft.com/en-us/library/h6ak8zt5.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/h6ak8zt5.aspx</a></p> <p>(compiled from several answers to <a href="https://stackoverflow.com/questions/334630/c-open-folder-and-select-the-file">this question</a>)</p> <hr> <p>Harder method, but more likely to work, taken from <a href="https://stackoverflow.com/questions/9355/programatically-select-multiple-files-in-windows-explorer/9497#9497">this answer to another question</a>:</p> <p>Use the shell function <a href="http://msdn.microsoft.com/en-us/library/h6ak8zt5.aspx" rel="nofollow noreferrer"><code>SHOpenFolderAndSelectItems</code></a></p> <p>Here is some sample code showing how to use the function in C/C++, without error checking:</p> <pre><code>//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); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload