代码拉取完成,页面将自动刷新
unit UnitDM;
interface
uses
SysUtils, Classes,SyncObjs;
type
TDMLJK = class(TDataModule)
procedure DataModuleCreate(Sender: TObject);
procedure DataModuleDestroy(Sender: TObject);
private
{ Private declarations }
public
FCsWriteLogFile:TCriticalSection;
exepath:string;
procedure MyAddlog(s:string);
procedure strToList(src: string; var ts: TStringList);
{ Public declarations }
end;
var
DMLJK: TDMLJK;
implementation
{$R *.dfm}
procedure TDMLJK.strToList(src: string; var ts: TStringList);
var
dec: string;
i: integer;
str: string;
begin
dec := ']';
if src = '' then
begin
ts.Add('');
exit;
end;
repeat
i := pos(dec, src);
str := copy(src, 1, i - 1);
if (str = '') and (i > 0) then
begin
delete(src, 1, length(dec));
continue;
end;
if i > 0 then
begin
ts.Add(str);
delete(src, 1, i + length(dec) - 1);
end;
until i <= 0;
if src <> '' then
ts.Add(src);
end;
procedure TDMLJK.MyAddlog(s:string);
var
tFile: TextFile;
filename: string;
b:Boolean;
begin
// if FormatDateTime('yyyyMMdd',now)>'20231230' then
// Abort;
filename:=exepath+'log';
b:=False;
if not(DirectoryExists(filename)) then
begin
try
ForceDirectories(filename);
b:=True;
except
end;
end
else
begin
b:=True;
end;
if b=False then exit;
filename:=filename+'\'+formatdatetime('yyyyMMdd',Now)+'.txt';
FCsWriteLogFile.Enter();
AssignFile(tFile,filename);
try
if FileExists(filename) then
Append(tFile)
else
Rewrite(tFile);
Writeln(tFile,'<'+FormatDateTime('hh:nn:ss', Now)+'>'+s);
except
end;
CloseFile(tFile);
FCsWriteLogFile.Leave;
end;
procedure TDMLJK.DataModuleCreate(Sender: TObject);
begin
exepath:=ExtractFilePath(ParamStr(0));
FCsWriteLogFile:=TCriticalSection.Create;
end;
procedure TDMLJK.DataModuleDestroy(Sender: TObject);
begin
FCsWriteLogFile.free;
end;
end.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。