开发者

How to locate a file in windows explorer

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.开发者_如何学Python Any Windows API can do that? Thanks in advance.


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

Explorer /select,C:\TestDir\TestApp.exe


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜