Display the Browse for Folder dialog box #63
Use the following routine to display the Windows "Browse for Folder" dialog box.
function FindFolder(Handle: THandle; Title: string = 'Please specify a folder'): string; var lpItemID: PItemIDList; BrowseInfo: TBrowseInfo; DisplayName: array[0..MAX_PATH] of char; TempPath: array[0..MAX_PATH] of char; begin 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 begin SHGetPathFromIDList(lpItemID, TempPath); Result := TempPath; GlobalFreePtr(lpItemID); end; end;
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 |