delphi如何调用window的folderBrowserDialog函数,选择文件目录.
解决方案 »
- Delphi 窗体关闭问题
- 坐标轴显示仪器测得的数据
- 动态创建后ShowModal()要释放吗?急急~~~~~~~急
- "进销存管理系统”和“进销存系统”有什么区别?
- 问个奇怪的问题,关于Automation
- 关于Activex控件内部进行数据库连接的问题
- 各位大哥帮我!跪拜!
- 为什么我的insert into编译通过,执行老报错,大家帮忙看看!我对单引号的概念比较模糊!
- 怎样用Delphi 写一个Quequ?
- 猜测招聘可能的问题,答上就给分!
- 问一个关于ORACLE中BLOB类型数据与TDBRICHEDIT(或TRXDBRICHEDIT)相结合的显示乱码问题
- 急求!!!用TQuery查询SQL Server2000数据库时的问题!——delphi菜鸟级问题
System.Windows.Forms.FolderBrowserDialog dlg = new FolderBrowserDialog();
if (dlg.ShowDialog() == DialogResult.OK)
{
MessageBox.Show(dlg.SelectedPath);
}
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.