1 2 //this code will display the windows Explorer Browser Dialog 3 4 unit Unit1; 5 6 interface 7 8 uses 9 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, 10 StdCtrls, FileCtrl,ShlObj; 11 12 type 13 TForm1 = class(TForm) 14 Button1: TButton; 15 dlb: TDirectoryListBox; 16 procedure Button1Click(Sender: TObject); 17 private 18 { Private declarations } 19 public 20 { Public declarations } 21 end; 22 23 var 24 Form1: TForm1; 25 26 implementation 27 28 {$R *.DFM} 29 30 31 function BrowseForFolder: string; 32 var 33 lpItemID: PItemIDList; 34 BrowseInfo: TBrowseInfo; 35 36 DisplayName: array[0..MAX_PATH] of char; 37 TempPath: array[0..MAX_PATH] of char; 38 begin 39 FillChar(BrowseInfo, sizeof(TBrowseInfo), #0); 40 with BrowseInfo do 41 begin 42 hwndOwner := Application.Handle; 43 pszDisplayName := @DisplayName; 44 lpszTitle := PChar(''); 45 ulFlags := BIF_RETURNONLYFSDIRS; 46 end; 47 lpItemID := SHBrowseForFolder(BrowseInfo); 48 if lpItemId <> nil then 49 begin 50 SHGetPathFromIDList(lpItemID, TempPath); 51 GlobalFreePtr(lpItemID); 52 Result := TempPath; 53 end 54 else 55 Result := ''; 56 57 end; 58 procedure TForm1.Button1Click(Sender: TObject); 59 begin 60 dlb.Directory:=BrowseForFolder; 61 end; 62 63 end.