BSOne.SFC/Tocsg.Module/MonSecu/ThdCollectMonInfo.pas

122 lines
2.9 KiB
Plaintext
Raw Blame History

{*******************************************************}
{ }
{ ThdCollectMonInfo }
{ }
{ Copyright (C) 2022 kku }
{ }
{*******************************************************}
unit ThdCollectMonInfo;
interface
uses
Tocsg.Thread, System.SysUtils, System.Classes, Winapi.Windows, ManagerMonInfo;
type
PMonSecuEnt = ^TMonSecuEnt;
TMonSecuEnt = record
sMonTxt: String;
end;
TThdCollectMonInfo = class(TTgThread)
private
dwInterval_,
dwSaveImgInterval_: DWORD;
PathInfo_: TCollectPathInfo;
protected
procedure Execute; override;
public
Constructor Create(aPathInfo: TCollectPathInfo);
end;
//function ExtrTxtFromDesktop: String;
implementation
//const
// DIR_TASK = 'Temp\';
//
//function ExtrTxtFromDesktop: String;
//var
// sCurDir,
// sImgPath,
// sTxtPath: String;
// fs: TFileStream;
// bResult: Boolean;
// StrList: TStringList;
//begin
// Result := '';
// sCurDir := GetRunExePathDir;
// sImgPath := sCurDir + DIR_TASK;
// if FileExists(sCurDir + EXE_OCR) and
// ForceDirectories(sImgPath) then
// begin
// sImgPath := sImgPath + FormatDateTime('yyyymmhhnnss', Now) + '.jpg';
// try
// fs := TFileStream.Create(sImgPath, fmCreate);
// bResult := CaptureDesktopAsJpegStream(fs);
// fs.Free;
// if bResult then
// begin
// sTxtPath := sImgPath + '.txt';
// ExecuteAppWaitUntilTerminate(sCurDir + EXE_OCR, Format('"%s" "%s"', [sImgPath, sTxtPath]), SW_HIDE, 60000);
// if FileExists(sTxtPath) then
// begin
// Guard(StrList, TStringList.Create);
// StrList.LoadFromFile(sTxtPath, TEncoding.UTF8);
// Result := StrList.Text;
// DeleteFile(PChar(sTxtPath));
// end;
// DeleteFile(PChar(sImgPath));
// end;
// except
// on E: Exception do
// ETgException.TraceException(E, 'Fail .. ExtrTxtFromDesktop()');
// end;
// end;
//end;
{ TThdCollectMonInfo }
Constructor TThdCollectMonInfo.Create(aPathInfo: TCollectPathInfo);
begin
Inherited Create;
PathInfo_ := aPathInfo;
// <20><20><><EFBFBD>͹<EFBFBD>
dwInterval_ := 5000;
dwSaveImgInterval_ := 60000 * 5;
end;
procedure TThdCollectMonInfo.Execute;
var
dwTick,
dwLTick,
dwSTick: DWORD;
MonInfo: TMonInfo;
bSaveImg: Boolean;
begin
dwLTick := 0;
dwSTick := 0;
while not Terminated and not GetWorkStop do
begin
dwTick := GetTickCount;
if (dwTick - dwLTick) > dwInterval_ then
begin
dwLTick := dwTick;
bSaveImg := (dwTick - dwSTick) > dwSaveImgInterval_;
if bSaveImg then
dwSTick := dwTick;
with TMonInfo.Create(PathInfo_, bSaveImg) do
begin
WriteLogToFileTail(PathInfo_.sLogPath);
Free;
end;
end;
end;
end;
end.