Notice Of Closure

Please note that this website is due to close down on 15th June 2020.

In the interim I will try to move as much content as possible over to my GitHub account. Thanks to everyone who has supported the site over the years.

» Help

Display the Browse for Folder dialog box


Use the following routine to display the Windows "Browse for Folder" dialog box.

function FindFolder(Handle: THandle;
  Title: string = 'Please specify a folder'): string;
  lpItemID: PItemIDList;
  BrowseInfo: TBrowseInfo;
  DisplayName: array[0..MAX_PATH] of char;
  TempPath: array[0..MAX_PATH] of char;
  Result := '';
  FillChar(BrowseInfo, sizeof(TBrowseInfo), #0);
  BrowseInfo.hwndOwner := Handle;
  BrowseInfo.pszDisplayName := @DisplayName;
  BrowseInfo.lpszTitle := PChar(Title);
  BrowseInfo.ulFlags := BIF_RETURNONLYFSDIRS;
  lpItemID := SHBrowseForFolder(BrowseInfo);
  if lpItemId <> nil then
    SHGetPathFromIDList(lpItemID, TempPath);
    Result := TempPath;

You will need to use the Windows and ShlObj units to get the code to compile.

Author: Joe Donth
Contributor: Joe Donth
Added: 2003-03-31
Last updated: 2003-03-31

« Return to contents »