CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Delphi >  Windows SDK/API

delphi如何调用window的folderBrowserDialog函数

楼主houlc()2005-04-03 10:49:28 在 Delphi / Windows SDK/API 提问

delphi如何调用window的folderBrowserDialog函数,选择文件目录. 问题点数:20、回复次数:2Top

1 楼Kshape(C/C++初学者~~~~)回复于 2005-04-03 22:30:18 得分 20

给个C#的代码吧  
  System.Windows.Forms.FolderBrowserDialog     dlg   =   new   FolderBrowserDialog();  
  if   (dlg.ShowDialog()   ==   DialogResult.OK)  
  {  
  MessageBox.Show(dlg.SelectedPath);  
   
  }Top

2 楼cnhgj(戏子) (没时间练太极)回复于 2005-04-03 23:00:33 得分 0

unit   Unit1;  
   
  interface  
   
  uses  
      Windows,   Messages,   SysUtils,   Variants,shlobj,   Classes,   Graphics,   Controls,   Forms,  
      Dialogs;  
   
  type  
      TForm1   =   class(TForm)  
          procedure   FormCreate(Sender:   TObject);  
      private  
          {   Private   declarations   }  
      public  
          {   Public   declarations   }  
      end;  
   
  var  
      Form1:   TForm1;  
   
  implementation  
   
  {$R   *.dfm}  
  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+BIF_EDITBOX;  
      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  
      begin  
        directory:=buf;  
        if   length(directory)<>3   then   directory:=directory+'\';  
      end;  
  end;  
   
  procedure   TForm1.FormCreate(Sender:   TObject);  
  var   dir:string;  
  begin  
  if   selectdirectory(handle,'请选择文件夹','',dir)   then   showmessage(dir);  
   
  end;  
   
  end.  
  Top

相关问题

  • delphi里怎么调用GetObjectContext()函数
  • 怎样在DELPHI中调用HTMLHELP()函数
  • delphi中如何调用dll的函数?
  • Delphi中如何调用API函数?
  • delphi中怎么调用随机函数
  • delphi中调用api()函数问题
  • 函数调用
  • 函数调用
  • 调用函数
  • 函数调用

关键词

  • folderbrowserdialog
  • lpbi
  • tform
  • dlg
  • dir
  • directory
  • handle
  • form
  • var

得分解答快速导航

  • 帖主:houlc
  • Kshape

相关链接

  • Delphi类图书
  • Delphi类源码下载
  • Delphi控件下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo