unit Unit1;
interface
uses
; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
; StdCtrls, ExtCtrls,shellAPI,filectrl;
type
; TForm1 = class(TForm)
; ; Panel1: TPanel;
; ; StaticText1: TStaticText;
; ; StaticText2: TStaticText;
; ; Edit1: TEdit;
; ; Edit2: TEdit;
; ; Button1: TButton;
; ; Button2: TButton;
; ; Button3: TButton;
; ; Button4: TButton;
; ; Button5: TButton;
; ; procedure Button1Click(Sender: TObject);
; ; procedure Button2Click(Sender: TObject);
; ; procedure Button3Click(Sender: TObject);
; ; procedure Button4Click(Sender: TObject);
; ; procedure Button5Click(Sender: TObject);
; private
; ; { Private declarations }
; public
; ; { Public declarations }
; end;
var
; Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
; Dir: string;
begin
; Dir := 'D:';
; if SelectDirectory(Dir, [sdAllowCreate, sdPerformCreate, sdPrompt],0) then
//函数执行成功
// sdAllowCreate:允许创建目录
// sdPerformCreate:执行创建目录
// sdPrompt:显示提示信息
; ; edit1.text:= Dir;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
; Dir: string;
begin
; Dir := 'D:';
; if SelectDirectory(Dir, [sdAllowCreate, sdPerformCreate, sdPrompt],0) then
;//解释同上
; ; edit2.text:= Dir;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
; OpStruc:TSHFileOpStruct;
; FromBuf,ToBuf:Array[0..128] of Char;
begin
; FillChar(FromBuf,Sizeof(FromBuf),0);
; FillChar(ToBuf,Sizeof(ToBuf),0);
; //用0初始化FromBuf和ToBuf数组
; StrPCopy(FromBuf,Pchar(Edit1.Text));
; StrPCopy(ToBuf,Pchar(Edit2.Text));
; //分别在 FromBuf和ToBuf数组中填入操作的源目录及目标目录
; //开始填充OpStruc记录
; with OpStruc do
; begin
; ; Wnd:=Handle;
; ; wFunc:=FO_COPY;
; //复制操作
; ; pFrom:=@FromBuf;
; ; pTo:=@ToBuf;
; ; fFlags:=FOF_NOCONFIRMATION or FOF_RENAMEONCOLLISION;
; ; fAnyOperationsAborted:=False;
; ; hNameMappings:=nil;
; ; lpszProgressTitle:=nil;
; end;
; if SHFileOperation(OpStruc)=0 then
;//函数执行成功
; MessageBox(Handle,'复制完毕。','复制信息',MB_OK+MB_ICONINFORMATION);
end;
procedure TForm1.Button4Click(Sender: TObject);
var
; OpStruc:TSHFileOpStruct;
; FromBuf,ToBuf:Array[0..128] of Char;
begin
; FillChar(FromBuf,Sizeof(FromBuf),0);
; FillChar(ToBuf,Sizeof(ToBuf),0);
; StrPCopy(FromBuf,Pchar(Edit1.Text));
; StrPCopy(ToBuf,Pchar(Edit2.Text));
; //开始填充OpStruc记录
; with OpStruc do
; begin
; ; Wnd:=Handle;
; ; wFunc:=FO_MOVE;
; ;//移动操作
; ; pFrom:=@FromBuf;
; ; pTo:=@ToBuf;
; ; fFlags:=FOF_NOCONFIRMATION or FOF_RENAMEONCOLLISION;
; ; fAnyOperationsAborted:=False;
; ; hNameMappings:=nil;
; ; lpszProgressTitle:='正在文件';
; end;
; if SHFileOperation(OpStruc)=0 then
; //执行成功
; MessageBox(Handle,'移动完毕。','移动信息',MB_OK+MB_ICONINFORMATION);
end;
procedure TForm1.Button5Click(Sender: TObject);
var
; OpStruc:TSHFileOpStruct;
; FromBuf:Array[0..128] of Char;
begin
; FillChar(FromBuf,Sizeof(FromBuf),0);
; StrPCopy(FromBuf,Pchar(Edit1.Text));
; //开始填充OpStruc记录
; with OpStruc do
; begin
; ; Wnd:=Handle;
; ; wFunc:=FO_DELETE;
; ; pFrom:=@FromBuf;
; ; pTo:=nil;
; ; fFlags:=FOF_NOCONFIRMATION;
; ; lpszProgressTitle:='正在删除';
; end;
; if SHFileOperation(OpStruc)=0 then
; //执行成功
; MessageBox(Handle,'删除完毕。','删除信息',MB_OK+MB_ICONINFORMATION);
end;
end.