⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 singletransferthreadunit.pas

📁 软件可自动完成SQL Server数据库和文档的数据定时自动备份
💻 PAS
字号:
unit SingleTransferThreadUnit;

interface

uses
  Classes, SysUtils, Windows;

type
  TSingleTransferThread = class(TThread)
  private
    { Private declarations }
  sFileName:String;
  aDirName:String;
  procedure SingleCopyDone;
  protected
    procedure Execute; override;
  public
    constructor Create(_sFileName,_aDirName:String);
  end;

implementation

{ Important: Methods and properties of objects in visual components can only be
  used in a method called using Synchronize, for example,

      Synchronize(UpdateCaption);

  and UpdateCaption could look like,

    procedure TSingleTransferThread.UpdateCaption;
    begin
      Form1.Caption := 'Updated in a thread';
    end; }

{ TSingleTransferThread }
uses
  TestFunctionUnit, FileTestUnit;
constructor TSingleTransferThread.Create(_sFileName,_aDirName:String);
begin
  sFileName:=_sFileName;
  aDirName:=_aDirName;
  inherited Create(True);
end;

procedure TSingleTransferThread.SingleCopyDone;
var
  noError:Boolean;
begin
  noError:=True;
  try
    if not CopyFile(PChar(sFileName),PChar(aDirName+'\'+ExtractFileName(sFileName)),False) then
      noError:=False;
  except
    if not SendFile(sFileName,aDirName+'\'+ExtractFileName(sFileName)) then
      noError:=False;
  end;
  if noError then
    FileTestForm.ListBox1.Items.Add('###'+sFileName)
  else
    FileTestForm.ListBox1.Items.Add('***'+sFileName);
end;

procedure TSingleTransferThread.Execute;
begin
  { Place thread code here }
  FreeOnTerminate:=True;
  synchronize(SingleCopyDone);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -