Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function SelectDirectory(const Title: string; var Path: string): Boolean;
- var
- 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 := 0;
- BrowseInfo.pszDisplayName := @DisplayName;
- BrowseInfo.lpszTitle := PChar(Title);
- BrowseInfo.ulFlags := BIF_RETURNONLYFSDIRS;
- lpItemID := SHBrowseForFolder(BrowseInfo);
- Result := lpItemID <> nil;
- if Result then
- begin
- SHGetPathFromIDList(lpItemID, TempPath);
- Path := TempPath;
- GlobalFreePtr(lpItemID);
- end;
- end;
- procedure Tmain.SpeedButton1Click(Sender: TObject);
- var
- chosenDirectory: string;
- begin
- if SelectDirectory('Выберите каталог', chosenDirectory) then
- Edit1.Text := chosenDirectory
- else
- ShowMessage('Выбор каталога прервался');
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement