tags:

views:

82

answers:

2

I have a application to list all music files in user machine, a "Explorer" button is using to quickly open Windows Explorer and highlight the file in Windows Explorer. I tried ShellExecute, but it doesn't work, the API will launch associate application. Any Windows API can do that? Thanks in advance.

+5  A: 

You can simply start explorer.exe with the /select argument, as detailed in this Knowledge Base article:

Explorer /select,C:\TestDir\TestApp.exe
Joey
Do you know the command line how to select mulit files by default
Yigang Wu
Doesn't seem to be possible.
Joey
A: 

You can create an IE instance and navigate to your folder, then query the IShellBrowser service from the top level browser service and get the active view's IShellView interface. Use IShellView::SelectItem to select items.

Remember to call IWebBrowser::Quit when you don't need the explorer window.

This method can not get around Windows Vista's User Interface Privilege Isolation. If the folder is opened in a process with a different integrity level, a broker IE extension is needed to continue the automation.

Sheng Jiang 蒋晟