function SelectDir:string
var
Info:TBrowseInfo;
IDList:PItemIDList;
Buffer:pchar;
begin
result :='';
Buffer:=StrAlloc(MAX_PATH);
with Info do
begin
hwndOwner:=Application.mainform.handle;
pidRoot :=nil;
pszDisplayName:=Buffer;
lpszTitle:='请选择路径:';
uFlags:=BIF_RETURNONLYFSDIRS; //如果加上OR BIF_BROWSEINCLUDEFILES则可显示子目录
lpfn :=nl;
lParam:=0;
IDList:=SHBrowseForFolder(Info);
end;
if IDList<>nil then
begin
SHGetPathFromIDList(IDList,Buffer);
result :=strpas(Buffer);
end;
StrDispose(Buffer);
end;