//
// Sample for SHBrowseForFolder function
//
var
Form1 : TForm1;
Shell : IShellFolder;
HRES : HRESULT;
procedure CallBack(Wnd: HWND; uMsg: UINT; lParam, lpData: LPARAM) stdcall;
Var
S : String;
begin
S := 'Choose folder for installation';
SendMessage(Wnd, BFFM_SETSTATUSTEXT, 0, LongInt(@S[1]));
end;
procedure TForm1.Button1Click(Sender: TObject);
var
InfoType : Byte;
BI : TBrowseInfo;
S : PChar;
Image : Integer;
PIDL : PItemIDList;
Path : Array[0..MAX_PATH-1] of WideChar;
ResPIDL : PItemIDList;
begin
SHGetSpecialFolderLocation(Handle, CSIDL_PROGRAMS, PIDL);
S := StrAlloc(128);
With BI do
Begin
hwndOwner := Form1.Handle;
pszDisplayName := S;
lpszTitle := 'Choose folder';
ulFlags := BIF_STATUSTEXT;
pidlRoot := PIDL;
lpfn := @CallBack;
iImage := Image;
End;
ResPIDL := SHBrowseForFolder(BI);
SHGetPathFromIDList(ResPIDL, @Path[0]);
Edit1.Text := StrPas(@Path[0]);
StrDispose(S);
end;
|