把数据库copy到其他目录,如下:
uses shellapi;
procedure Tmain.copy_file(fromfile,tofile:string);
var
frombuf,tobuf:Array[0..128] of char;
opstruc:TSHFileOpstruct;
begin
fillchar(frombuf,sizeof(frombuf),0);
fillchar(tobuf,sizeof(tobuf),0);
strpcopy(frombuf,fromfile);
strpcopy(tobuf,tofile);
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
begin
messagedlg('复制文件出错!',mtinformation,[mbok],0);
exit;
end;
end;
///////////////////////////////////////////////////////////////////
if fileexists(main.exefilepathstr+'/个人申报/个人申报材料.mdb') then
begin
main.copy_file(main.exefilepathstr+'/个人申报/个人申报材料.mdb','a:/个人申报/个人申报材料.mdb');
FileSetAttr('a:/个人申报/个人申报材料.mdb',faHidden);
form1.ppp.StepIt;
end