Delphi 快速选择文件夹路径


本文整理自网络,侵删。

 
uses  ShlObj;

function FindFolder(Handle: THandle; Title: string = '请选择文件夹路径'): 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//delphitop.com
  begin
    SHGetPathFromIDList(lpItemID, TempPath);
    Result := TempPath;
    GlobalFreePtr(lpItemID);
  end;
end;



procedure TForm2.Button1Click(Sender: TObject);

begin
Caption:=FindFolder(Self.Handle);
end;

相关阅读 >>

Delphi 正则表达式起步

maskedit中掩码的含义及使用

Delphi 自动关闭弹出的窗口

Delphi遍历所有控件

Delphi delete 删除字符串中指定的字符串

Delphi tms web core直接从html&css设计的页面布局

Delphi findwindow的一些用法

Delphi 删除或清除tstringgrid中的行

Delphi中用idhttp获取json数据乱码问题

Delphi 限制edit输入 多个例子

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...