文件拷贝的函数

      编程资料 2004-12-20 20:23
文件拷贝的函数


文件拷贝的函数,只要输入源文件和目标文件名即可。
// 设置文件拷备函数
function WinCOPY(SourceFileName: String; TargetFileName: String): String;
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(SourceFileName));
StrPCopy(ToBuf,Pchar(TargetFileName));
//分别在 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;
OpStR:= SHFileOperation(OpStruc);
end;
end;
标签集:TAGS:
回复Comments() 点击Count()

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}