Posted by Jenny, DelphiLand Team on February 04, 2008
In Reply to Show contents of folder posted by Newb p15701 on
February 04, 2008
: How can I show the contents of a folder in the Windows interface, just as if the
user opened that folder in My Computer? (without showing the folder-navigating panel of Windows Explorer)
:
Thanks!
To "explore" a folder showing two panes, folders navigation at the left and contents of the folder to the right, you use the following Delphi source code:
ShellExecute(Handle, 'explore', PChar(Folder_To_Show), nil, nil, SW_SHOW)
But if you launch Windows' Explorer.exe with the path of the folder as a parameter, the left navigation pane is not shown. Also for this you use ShellExecute, but with slightly different parameters:
ShellExecute(Handle, 'open', PChar('explorer.exe'), PChar(Folder_to_Show), nil, SW_SHOW)
For example, to open the folder D:\Music, use the following source code:
procedure TForm1.Button1Click(Sender: TObject); begin ShellExecute(Handle, 'open', PChar('explorer.exe'), PChar('D:\Music'), nil, SW_SHOW); end;
Example to open the folder whose full path was entered in an edit-box:
procedure TForm1.Button2Click(Sender: TObject); begin ShellExecute(Handle, 'open', PChar('explorer.exe'), PChar(Edit1.Text), nil, SW_SHOW); end;
Related articles
Follow Ups