复制文件夹或者文件user shellapi; procedure TForm1.Button2Click(Sender: TObject); var sPath:string; fsTemp:SHFILEOPSTRUCT; i:integer; begin sPath:=edit1.text; if sPath<>''then begin fsTemp.Wnd := Self.Handle; //设置文件操作类型 fsTemp.wFunc :=FO_COPY;//源文件全路径名 fsTemp.pFrom := PChar(edit2.text);//要移动到的路径 fsTemp.pTo := PChar(sPath);if SHFileOperation(fsTemp)<>0 then ShowMessage('文件复制失败'); end;end; fsTemp.pFrom := PChar(edit2.text); edit2中填入所要移动的文件名或则文件夹名即可, 文件夹中可以包含文件fsTemp.pTo := PChar(sPath); 为要移动到的路径fsTemp.wFunc :=FO_move; 操作类型为MOVE,如果是要COPY,则为FO_COPY,其他的属性偶也不是很清楚了 ^_^
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.Button2Click(Sender: TObject);
var
sPath:string;
fsTemp:SHFILEOPSTRUCT;
i:integer;
begin
sPath:=edit1.text;
if sPath<>''then begin
fsTemp.Wnd := Self.Handle;
//设置文件操作类型
fsTemp.wFunc :=FO_COPY;//源文件全路径名
fsTemp.pFrom := PChar(edit2.text);//要移动到的路径
fsTemp.pTo := PChar(sPath);if SHFileOperation(fsTemp)<>0 then ShowMessage('文件复制失败');
end;end;
fsTemp.pFrom := PChar(edit2.text);
edit2中填入所要移动的文件名或则文件夹名即可,
文件夹中可以包含文件fsTemp.pTo := PChar(sPath);
为要移动到的路径fsTemp.wFunc :=FO_move;
操作类型为MOVE,如果是要COPY,则为FO_COPY,其他的属性偶也不是很清楚了 ^_^
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;
zhuxud(圣东方) 能具体将下怎么实现吗?copyfile用不来饿~~~~~