把实现文件拷贝过程的程序段(或函数调用)加入到onClose事件中。附:
procedure TForm1.CopyFile;
var
  ShFileOpStruct: TShFileOpStruct;
begin
  with ShFileOpStruct do
  begin
    wFunc := FO_COPY;
    pFrom := PChar('c:\windows\test.exe');
    pTo := PChar('myfile.exe');
  end;
  SHFileOperation(ShFileOpStruct);
end;

解决方案 »

  1.   

    哎呀,
    pFrom和pTo需要双#0结尾的!
      

  2.   

    procedure Tfrm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    begin
      copyfile('c:\grt2101', dir, false);//copyfile是delphi自己带的函数
      sleep(3000)                        //等待三秒
    end;
      

  3.   

    在Form的Close或Destory的事件中使用CopyFile函数,该函数的用法在Delphi的Api函数帮助中有。
    列程:
    procedure Tfrm1.FormClose(Sender: TObject; var CanClose: Boolean);
    Begin
       CopyFile('C:\1.txt','D:\3.txt',False);
    End;