有一个TOpenDialog组件:
procedure TPPMS010.sptbtnDirClick(Sender: TObject);
begin
  if OpenDlg.Execute then
    edtDir.Text :=OpenDlg.FileName;
end;

解决方案 »

  1.   

    OpenDlg.FileName:='c:\temp'//这样打开时显示的目录是c:\temp
    if  OpenDlg.Execute  then
    edtDir.Text  :=OpenDlg.FileName;//OpenDlg.FileName就是路径加文件名
      
      

  2.   

    用TDriveComboBox和TDirectoryListBox控件就可以了
      

  3.   

    uses FileCtrl;
      if SelectDirectory(Dir, [sdAllowCreate, sdPerformCreate, sdPrompt],SELDIRHELP) then
        Label1.Caption := Dir;
      

  4.   

    uses FileCtrl;
      if SelectDirectory(Dir, [sdAllowCreate, sdPerformCreate, sdPrompt],SELDIRHELP) then
        Label1.Caption := Dir;
      

  5.   

    uses FileCtrl;
      if SelectDirectory(Dir, [sdAllowCreate, sdPerformCreate, sdPrompt],SELDIRHELP) then
        Label1.Caption := Dir;
      

  6.   

    同意chechy的,这个函数用起来非常方便。
      

  7.   

    function SelectDirectory(handle:hwnd;const Caption: string; const Root: WideString;out Directory: string): Boolean;
    var
    lpbi:_browseinfo;
    buf:array [0..MAX_PATH] of char;
    id:ishellfolder;
    eaten,att:cardinal;
    rt:pitemidlist;
    initdir:pwidechar;
    begin
    result:=false;
    lpbi.hwndOwner:=handle;
    lpbi.lpfn:=nil;
    lpbi.lpszTitle:=pchar(caption);
    lpbi.ulFlags:=BIF_RETURNONLYFSDIRS+16;
    SHGetDesktopFolder(id);
    initdir:=pwchar(root);
    id.ParseDisplayName(0,nil,initdir,eaten,rt,att);
    lpbi.pidlRoot:=rt;
    getmem(lpbi.pszDisplayName,MAX_PATH);
    try
    result:=shgetpathfromidlist(shbrowseforfolder(lpbi),buf);
    except
    freemem(lpbi.pszDisplayName);
    end;
    if result then directory:=buf;
    end;uses ShellApi;
      

  8.   

    当然使用 chechy(chechy)所说的SelectDirectory函数,很方便的。