function SelectDirectory(const Caption: string; const Root: WideString; out Directory: string): Boolean;

解决方案 »

  1.   

    有呀,自己写个函数就行
    procedure TForm1.Btn_BroweFolderClick(Sender: TObject);
    var
      FolderStr:String;
      bi:TBROWSEINFO;
      Str:array[0..MAX_PATH] of Char;
      pIDListItem:PItemIDList;
      pStr:PChar;
      Executed:Boolean;
    begin
      pStr:=nil;
      bi.hwndOwner:=GetActiveWindow;
      bi.pidlRoot:=nil;
      bi.pszDisplayName:=@str;
      bi.ulFlags:=BIF_RETURNONLYFSDIRS;
      bi.lpfn:=nil;
      bi.lpszTitle:='选择查找加密文件的目录……';
      pIDListItem:=SHBrowseForFolder(bi);
      if pIDListItem<>nil then
      begin
        pStr:=@Str;
        SHGetPathFromIDList(pIDListItem, pStr);
    //    CoTaskMemFree(pIDListItem);
        Executed:=True;
      end
      else
        Executed:=False;  if Executed then
      begin
        cb_SearchAllDisk.Checked:=False;
        FolderStr:=pStr;
        if Length(FolderStr)>3 then FolderStr:=FolderStr+'\';
        Edit_SearchDir.Text:=FolderStr;
      end;
    end;