SelectDirectory在Delphi中定位文件夹位置

//SelectDirectory在Delphi中定位文件夹位置 
procedureTForm1.Button1Click(Sender: TObject);//直接定位文件' 打开一个文件
begin
  OpenDialog1.Execute;//执行“打开”文件对话框
  Label1.Caption:=OpenDialog1.FileName;//将返回的结果值传递给控件Label1
    //要注意,只有当用户选择了一个文件并且按了“确定”按钮后才能返回此结果。
  Label1.Refresh;
end;
 //直接定位到文件夹的实现代码
usesFileCtrl;


procedureTForm1.Button2Click(Sender: TObject);
var
  strDirectory:String;
  wstrRoot:WideString;
begin
  wstrRoot:='';//这个参数表示所显示的浏览文件夹窗口中的根目录,默认或空表示“我的电脑”。
  SelectDirectory('这里写说明文字',wstrRoot,strDirectory);
  Label2.Caption:=strDirectory;//传递结果,其中参数strDirectory表示函数的返回值
  Label2.Refresh;
end;




原文地址:https://www.cnblogs.com/xe2011/p/2531623.html