小弟通过ODBC连接一个数据文件,而这个数据文件需要定时从别的电脑COPY过来,
当COPY过来时会出现复制文件出错,提示什么文件正在使用ODBC 是连接Pervasive SQL 7 数据库如何强制覆盖原文件请各位大虾们 帮帮忙 ! 谢谢 。

解决方案 »

  1.   

    uses shellapi;
    Function   Copy_Dir(SourceDir,DestDir:String;nLx:Integer):Boolean; 
           Var 
                 Opstruc:   TshFileOpStruct; 
                 frombuf,tobuf:   Array[0..128]   of   Char; 
           begin 
                 FillChar(frombuf,Sizeof(frombuf),0); 
                 FillChar(tobuf,Sizeof(tobuf),0); 
                 StrPcopy(frombuf,SourceDir); 
                 Case   nLx   of 
                                1: 
                                      StrPcopy(tobuf,DestDir); 
                 end; 
                 With   Opstruc   Do 
                 Begin 
                                Wnd:=0; 
                                Case   nLx   of 
                                            1:   wFunc:=FO_COPY; 
                                            2:   wFunc:=FO_DELETE; 
                                            Else   wFunc:=FO_COPY; 
                                end; 
                                pFrom:=@frombuf; 
                                pTo:=@tobuf; 
                                fFlags:=FOF_NOCONFIRMATION; 
                                fAnyOperationsAborted:=False; 
                                hNameMappings:=Nil; 
                                lpszProgressTitle:=Nil; 
                 end; 
                 try 
                                ShFileOperation(OpStruc); 
                                Result:=True; 
                 except 
                                Result:=False; 
                 end; 
           end;