Board index » delphi » virtual folders

virtual folders

hii,

how can i get contents of a virtual folder like My Computer or Desktop?

tia, ales

 

Re:virtual folders


Quote
Ales Hotko <ales.ho...@uni-mb.si> wrote in message

news:380D910E.A62F384D@uni-mb.si...

Quote

> how can i get contents of a virtual folder like My Computer or Desktop?

uses ShlObj;

const
  BIF_BROWSEINCLUDEFILES = $4000;    // declaration only needed for D2

procedure TForm1.BrowseFolders;
var
  BrowseInfo: TBrowseInfo;
  IDList, IDRoot: PItemIDList;
  Path: array[0..MAX_PATH] of Char;
begin
  // Get the Item ID for the Desktop
  SHGetSpecialFolderLocation(Handle, CSIDL_DESKTOP, IDRoot);
  // See the help on SHGetSpecialFolderLocation for a list of CSIDL_
  // constants
  ZeroMemory(@BrowseInfo, SizeOf(TBrowseInfo));
  with BrowseInfo do
  begin
    hwndOwner := Handle;
    pidlRoot := IDRoot;
    // Set pidlRoot to nil if you want the contents of My Computer
    lpszTitle := PChar('Select a folder');
    // Include this flag to show files as well as folders
    ulFlags := BIF_BROWSEINCLUDEFILES;
  end;
  // Show the browse dialog, get the Item ID for the selected item and
  // convert it to a path
  IDList := SHBrowseForFolder(BrowseInfo);
  SHGetPathFromIDList(IDList, Path);
  ShowMessage(Path);
end;

--
Stephen Brown

Other Threads