Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
procedure TForm1.Button1Click(Sender: TObject);
var
TitleName : string;
lpItemID : PItemIDList;
BrowseInfo : TBrowseInfo;
DisplayName : array[0..MAX_PATH] of char;
TempPath : array[0..MAX_PATH] of char;
begin
FillChar(BrowseInfo, sizeof(TBrowseInfo), #0);
BrowseInfo.hwndOwner := Handle;
BrowseInfo.pszDisplayName := @DisplayName;
TitleName := 'Please specify a directory';
BrowseInfo.lpszTitle := PChar(TitleName);
BrowseInfo.ulFlags := BIF_RETURNONLYFSDIRS;
lpItemID := SHBrowseForFolder(BrowseInfo);
if lpItemId <> nil then begin
SHGetPathFromIDList(lpItemID, TempPath);
ShowMessage(TempPath);
GlobalFreePtr(lpItemID);
end;
end;
unit d3_bdir;
{ revision 3, Shell BrowseDirectory }
interface
function BrowseDirectory(handle: cardinal; Title, startdir: string;
var outdir: string): Boolean;
implementation
uses windows, shlobj;
function BD_Callback(wnd: hwnd; umsg: uint;
lparam, lpdata: lparam): integer stdcall;
{ delphi.about.com, centers browse directory dialog }
var
wa, rect: TRect;
dialogPT: TPoint;
begin
if uMsg = BFFM_INITIALIZED then
begin
wa.Top := 0; wa.Left := 0;
Wa.Right := GetSystemMetrics(SM_CXSCREEN);
Wa.Bottom := GetSystemMetrics(SM_CYSCREEN);
GetWindowRect(Wnd, Rect);
dialogPT.X := ((wa.Right - wa.Left) div 2) -
((rect.Right - rect.Left) div 2);
dialogPT.Y := ((wa.Bottom - wa.Top) div 2) -
((rect.Bottom - rect.Top) div 2);
MoveWindow(Wnd, dialogPT.X, dialogPT.Y, rect.Right - Rect.Left,
Rect.Bottom - Rect.Top, True);
{ set browse directory }
SendMessage(wnd, BFFM_SETSELECTIONA, Longint(true), lpdata);
end;
Result := 0;
end;
function BrowseDirectory(handle: cardinal; Title, startdir: string;
var outdir: string): Boolean;
{ delphi.about.com, browse directory dialog }
var
lpItemID : PItemIDList;
BrowseInfo : TBrowseInfo;
DisplayName : array[0..MAX_PATH] of char;
TempPath : array[0..MAX_PATH] of char;
flag: integer;
begin
Flag := BIF_RETURNONLYFSDIRS;
FillChar(BrowseInfo, sizeof(TBrowseInfo), #0);
with BrowseInfo do begin
hwndOwner := Handle;
pszDisplayName := @DisplayName;
lpszTitle := PChar(Title);
lpfn := BD_Callback;
lparam := Longint(PChar(StartDir));
ulFlags := Flag;
end;
lpItemID := SHBrowseForFolder(BrowseInfo);
if lpItemId <> nil then
begin
SHGetPathFromIDList(lpItemID, TempPath);
outdir := temppath;
Result := true;
GlobalFreePtr(lpItemID);
end
else
Result := false;
end;
end.