开发者

How do I display Explorer with a file selected?

What's the API call to display an Explorer window with a specified file selected? Exactly as happens when you click the "Find Target..." button in the Properties dialog of a .lnk shortcut? I know there is function (or an interface method) for that, but I forgot th开发者_如何学编程e name, and cannot find it again.

Note that I'm aware of explorer /select,<pathname> command line and not interested in using it instead of API call.


This function opens explorer, and selects the specified file:

uses ShellAPI, ...;

procedure TForm1.ShowFile(const aFileName:String);
begin
  ShellExecute(Handle, 'OPEN', PChar('explorer.exe'), PChar('/select, "' + aFileName + '"'), nil, SW_NORMAL)
end;

procedure TForm1.ShowFolder(const aPath:String);
begin
  ShellExecute(Handle, 'OPEN', PChar('explorer.exe'), PChar('/root, "' + aPath + '"'), nil, SW_NORMAL) 
end;

Or is this the "commandline" that you didn't want to use?


You need SHOpenFolderAndSelectItems. This question was early discussed here - Programmatically selecting file in explorer
Dont forget to call CoInitialize before first use of SHOpenFolderAndSelectItems


You're looking for IExplorerBrowser::BrowseToObject, I think. Based on the very vague, non-specific question and comments with no additional information when asked for it, it's the best guess I can provide. IExplorerBrowser has a lot of additional functionality you may want to explore as well, in case this specific method isn't exactly what you're looking to find.


Since you wanted a name only: IShellLink?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜