procedure TForm1.BitBtn1Click(Sender: TObject);
var
  bInfo : BROWSEINFO;
  FSelectedDir : array[0..255] of char;
begin
  bInfo.hwndOwner := Self.WindowHandle ;
  bInfo.pidlRoot := nil;
  bInfo.lpszTitle := '';
  bInfo.ulFlags :=  BIF_RETURNONLYFSDIRS ;
  bInfo.lpfn := nil;
  bInfo.pszDisplayName :=FSelectedDir;  if SHBrowseForFolder(bInfo) <> nil then
    Edit1.Text := FSelectedDir;end;但是:
    FSelectedDir只显示目录名,没有完全的路径,请赐教,谢谢。

解决方案 »

  1.   

    Brings up a dialog to allow the user to enter a directory name.UnitFileCtrlCategorydialog and message routinesfunction SelectDirectory(const Caption: string; const Root: WideString; out Directory: string): Boolean; overload;
    function SelectDirectory(var Directory: string; Options: TSelectDirOpts; HelpCtx: Longint): Boolean; overload;DescriptionCall SelectDirectory to let the user enter a directory name. Use the first syntax to display the Windows directory browser. The Caption parameter specifies a caption for the dialog. The Root parameter specifies the root directory from which to browse. The selected directory is returned as the Directory parameter. Use the second syntax to call the Select Directory dialog box. The directory passed to the function with the Directory parameter appears as the currently selected directory when the dialog box appears. The name of the directory the user selects becomes the value of Directory when the function returns. The dialog does not change the value of the current directory.The HelpCtx parameter is the help context ID number.The Options parameter is a set of values. If Options is the empty set, the user can only select a directory that already exists. No edit box is provided for the user to enter a new directory name. If Options is not empty, the included values determine how the dialog responds when the user types a nonexistent directory name.With either syntax, SelectDirectory returns True if the user selected a directory and chose OK, and False if the user chose Cancel or closed the dialog box without selecting a directory.
      

  2.   

    s := ExtractFilePath(Application.ExeName);