本文整理自网络,侵删。
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);
beginCaption:=FindFolder(Self.Handle);end;
相关阅读 >>
Delphi tms web core直接从html&css设计的页面布局
更多相关阅读请进入《Delphi》频道 >>