📄 singlesizethreadunit.pas
字号:
unit SingleSizeThreadUnit;
interface
uses
Classes, SysUtils;
type
TSingleSizeThread = class(TThread)
private
{ Private declarations }
sFileName:String;
procedure GetSingleFileSize;
protected
procedure Execute; override;
public
constructor Create(_sFileName: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 TSingleSizeThread.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }
{ TSingleSizeThread }
uses
FileTestUnit, TestFunctionUnit;
constructor TSingleSizeThread.Create(_sFileName:String);
begin
sFileName:=_sFileName;
inherited Create(True);
end;
procedure TSingleSizeThread.GetSingleFileSize;
var
getStr:String;
begin
getStr:=DateTimeToStr(now)+','+ExtractFileName(sFileName)+' 的大小为:'+FormatFloat('#,##0.00',GetFileSize(sFileName))+'KB';
FileTestForm.ListBox1.Items.Add(getStr);
end;
procedure TSingleSizeThread.Execute;
begin
{ Place thread code here }
FreeOnTerminate:=True;
synchronize(GetSingleFileSize);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -