如何让选择文件夹框打开时 显示上次打开的路径
uses
ShlObj;
function SelectFolderDialog(const Handle: integer;
const Caption: string;
const InitFolder: WideString;
var SelectedFolder: string): boolean;
var
BInfo: _browseinfo;
Buffer: array[0..MAX_PATH] of
Char;
ID: IShellFolder;
Eaten, Attribute: Cardinal;
ItemID:
PItemidlist;
begin
Result := False;
BInfo.HwndOwner := Handle;
BInfo.lpfn := nil;
BInfo.lpszTitle := Pchar(Caption);
BInfo.ulFlags := BIF_RETURNONLYFSDIRS + BIF_NEWDIALOGSTYLE;
SHGetDesktopFolder(ID);
ID.ParseDisplayName(0, nil,
PWideChar(InitFolder), Eaten, ItemID, Attribute);
BInfo.pidlRoot := ItemID;
GetMem(BInfo.pszDisplayName, MAX_PATH);
try
if SHGetPathFromIDList(SHBrowseForFolder(BInfo), Buffer) then
begin
SelectedFolder := Buffer;
if Length(SelectedFolder) <> 3 then SelectedFolder := SelectedFolder + '\';
result := True;
end
else
begin
SelectedFolder := '';
Result := False;
end;
finally
FreeMem(BInfo.pszDisplayName);
end;
end;
var
NewDir: string;
调用
if SelectFolderDialog(handle, '选择文件夹', '', NewDir) then
xxxx
使用如上的方法显示选择文件夹框
但是无法让它显示上次打开的路径。
请大家给予一些帮助,谢谢
[解决办法]
为什么不用TOpenDialog?
[解决办法]
这样不就得了