singletransferthreadunit.pas
来自「软件可自动完成SQL Server数据库和文档的数据定时自动备份」· PAS 代码 · 共 71 行
PAS
71 行
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 + =
减小字号Ctrl + -
显示快捷键?