?? 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 + -