部分代码:
VAR
Fos : TSHFileOpStruct;
Buf : array[0..400] of char;
p : pchar;
begin
//读取需要备份的文件列表
FillChar(Buf, sizeof(Buf), #0) ;
p := @buf;
p := StrECopy(p, 'D:/OPERView/*.par') + 1;
p := StrECopy(p, 'D:/OPERView/*.dll') + 1;
p := StrECopy(p, 'D:/OPERView/*.res') + 1;
p := StrECopy(p, 'D:/OPERView/*.seq') + 1;
p := StrECopy(p, 'D:/OPERView/*.exe') + 1;
。
。
p := StrECopy(p, 'D:/OPERView/GradFile') + 1;
sDest := 'e:/operview backup/';
FillChar(Fos, sizeof(Fos), #0) ;
//开始备份
with Fos do
begin
Wnd := Handle;
wFunc := FO_COPY;
pFrom := @Buf;
pTo := pchar(sDest+trim(Edit1.Text)+','+FormatDateTime('yyyy-mm-dd hh-mm-ss',Now)+','+trim(Edit2.Text));
fFlags := 0;
if ((SHFileOperation(Fos) <> 0) or
(Fos.fAnyOperationsAborted <> false)) then
ShowMessage('Operation was canceled by the user')