![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
OpenDir [D6]
Dir © (2004-07-16 20:12:00)Как можно вывести окно выбора директории?
Григорьев Антон (2004-07-17 08:16:00) [1]Функция SelectDirectiry из модуля FileCtrl
Dimaxx (2004-07-16 23:56:00) [2]Тьфу, нет его там. Вот декларация...
function SHBrowseForFolder(var lpbi: TBrowseInfo): PItemIDList; stdcall; external 'shell32.dll' name 'SHBrowseForFolderA';
TBrowseInfo = record
hwndOwner: HWND;
pidlRoot: PItemIDList;
pszDisplayName: PAnsiChar; { Return display name of item selected. }
lpszTitle: PAnsiChar; { text to go in the banner over the tree. }
ulFlags: UINT; { Flags that control the return stuff }
lpfn: Pointer; //TFNBFFCallBack;
lParam: LPARAM; { extra info that's passed back in callbacks }
iImage: Integer; { output var: where to return the Image index. }
end;
Dimaxx (2004-07-16 23:55:00) [3]SHBrowseForFolder из shellapi
Dolt (2004-07-16 22:15:00) [4]Function ExploreFolder(Title:String;Var Dir:String):Boolean;
var
Malloc: IMalloc;
Desktop: IShellFolder;
pidlMyComputer: PItemIDList;
pidlResult: PItemIDList;
pidlInitialFolder: PItemIDList;
bi: TBrowseInfo;
ProgramFilesDir: WideString;
CharsDone: ULONG;
dwAttributes: DWORD;
begin
result:=False;
if SUCCEEDED(SHGetMalloc(Malloc)) then
try // acquire shell namespace root folder
if SUCCEEDED( SHGetDesktopFolder( Desktop ) ) then
try // acquire folder that will serve as root in dialog
if SUCCEEDED( SHGetSpecialFolderLocation( 0, CSIDL_DRIVES, pidlMyComputer ) ) then
try // acquire PIDL for folder that will be selected by default
if
SUCCEEDED(
Desktop.ParseDisplayName( 0, nil, PWideChar(ProgramFilesDir), CharsDone,
pidlInitialFolder, dwAttributes ))
then
try
SetLength(Dir, MAX_PATH );
FillChar( bi, sizeof(bi), 0 );
bi.pidlRoot := pidlMyComputer; // roots from 'My Computer'
bi.pszDisplayName := PChar(Dir);
bi.lpszTitle := PChar(Title);
bi.ulFlags := BIF_STATUSTEXT;
pidlResult := SHBrowseForFolder( bi );
if Assigned(pidlResult) then
try
SetLength(Dir, MAX_PATH );
result:=true;
SHGetPathFromIDList( pidlResult, PChar(Dir));
Dir:=String(PChar(Dir));
finally
Malloc.Free( pidlResult ); // release returned value
end;
finally
Malloc.Free( pidlInitialFolder ); // release PIDL for folder that
// was selected by default
end;
finally
Malloc.Free( pidlMyComputer ); // release folder that was served as root in dialog
end;
finally
Desktop := nil; // release shell namespace root folder
end;
finally
Malloc := nil; // release shell's allocator
end;
end;
(c) Не мое - нашел в инете