How do I display Explorer with a file selected?

后端 未结 4 537
生来不讨喜
生来不讨喜 2021-02-08 17:23

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

相关标签:
4条回答
  • 2021-02-08 17:37

    Since you wanted a name only: IShellLink?

    0 讨论(0)
  • 2021-02-08 17:50

    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.

    0 讨论(0)
  • 2021-02-08 17:58

    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?

    0 讨论(0)
  • 2021-02-08 18:03

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

    0 讨论(0)
提交回复
热议问题