📄 main.pas
字号:
Log('APM.SaveToStorage...');
SaveToStorage(ss);
Log('APM.LoadFromStorage...');
LoadFromStorage(ss);
end;
Log('APM.Destroy...');
Free;
hsf:=GetHeapStatus;
if hsf.TotalAllocated>hss.TotalAllocated then begin
tl:=tl+hsf.TotalAllocated-hss.TotalAllocated;
Log(Format('*MEMORY LEAK = %d B',[hsf.TotalAllocated-hss.TotalAllocated]));
end;
Log('');
end;
end;
except on e: Exception do begin
Inc(ec);
Log(Format('*ERROR = %s'#13#10,[e.Message]));
end end;
try
if clb.Checked[clb.Items.IndexOf('Disk')] then begin
Log('Disk.Create...');
hss:=GetHeapStatus;
with TMiTeC_Disk.Create(nil) do begin
onDebug:=MiTeC_Debug;
//ExceptionModes:=[emExceptionStack,emJournal];
Log('Disk.RefreshData...');
RefreshData;
Log('Disk.SetDisk...');
Drive:='C';
if cbxReport.Checked then begin
Log('Disk.SaveToStorage...');
SaveToStorage(ss);
Log('Disk.LoadFromStorage...');
LoadFromStorage(ss);
end;
Log('Disk.Destroy...');
Free;
hsf:=GetHeapStatus;
if hsf.TotalAllocated>hss.TotalAllocated then begin
tl:=tl+hsf.TotalAllocated-hss.TotalAllocated;
Log(Format('*MEMORY LEAK = %d B',[hsf.TotalAllocated-hss.TotalAllocated]));
end;
Log('');
end;
end;
except on e: Exception do begin
Inc(ec);
Log(Format('*ERROR = %s'#13#10,[e.Message]));
end end;
try
if clb.Checked[clb.Items.IndexOf('Printers')] then begin
Log('Printers.Create...');
hss:=GetHeapStatus;
with TMiTeC_Printers.Create(nil) do begin
onDebug:=MiTeC_Debug;
//ExceptionModes:=[emExceptionStack,emJournal];
Log('Printers.RefreshData...');
RefreshData;
if cbxReport.Checked then begin
Log('Printers.SaveToStorage...');
SaveToStorage(ss);
Log('Printers.LoadFromStorage...');
LoadFromStorage(ss);
end;
Log('Printers.Destroy...');
Free;
hsf:=GetHeapStatus;
if hsf.TotalAllocated>hss.TotalAllocated then begin
tl:=tl+hsf.TotalAllocated-hss.TotalAllocated;
Log(Format('*MEMORY LEAK = %d B',[hsf.TotalAllocated-hss.TotalAllocated]));
end;
Log('');
end;
end;
except on e: Exception do begin
Inc(ec);
Log(Format('*ERROR = %s'#13#10,[e.Message]));
end end;
try
if clb.Checked[clb.Items.IndexOf('Software')] then begin
Log('Software.Create...');
hss:=GetHeapStatus;
with TMiTeC_Software.Create(nil) do begin
//ExceptionModes:=[emExceptionStack,emJournal];
Log('Software.RefreshData...');
RefreshData;
if cbxReport.Checked then begin
Log('Software.SaveToStorage...');
SaveToStorage(ss);
Log('Software.LoadFromStorage...');
LoadFromStorage(ss);
end;
Log('Software.Destroy...');
Free;
hsf:=GetHeapStatus;
if hsf.TotalAllocated>hss.TotalAllocated then begin
tl:=tl+hsf.TotalAllocated-hss.TotalAllocated;
Log(Format('*MEMORY LEAK = %d B',[hsf.TotalAllocated-hss.TotalAllocated]));
end;
Log('');
end;
end;
except on e: Exception do begin
Inc(ec);
Log(Format('*ERROR = %s'#13#10,[e.Message]));
end end;
try
if clb.Checked[clb.Items.IndexOf('MSProduct')] then begin
Log('MSProduct.Create...');
hss:=GetHeapStatus;
with TMiTeC_MSProduct.Create(nil) do begin
onDebug:=MiTeC_Debug;
//ExceptionModes:=[emExceptionStack,emJournal];
Log('MSProduct.RefreshData...');
RefreshData;
if cbxReport.Checked then begin
Log('MSProduct.SaveToStorage...');
SaveToStorage(ss);
Log('MSProduct.LoadFromStorage...');
LoadFromStorage(ss);
end;
Log('MSProduct.Destroy...');
Free;
hsf:=GetHeapStatus;
if hsf.TotalAllocated>hss.TotalAllocated then begin
tl:=tl+hsf.TotalAllocated-hss.TotalAllocated;
Log(Format('*MEMORY LEAK = %d B',[hsf.TotalAllocated-hss.TotalAllocated]));
end;
Log('');
end;
end;
except on e: Exception do begin
Inc(ec);
Log(Format('*ERROR = %s'#13#10,[e.Message]));
end end;
try
if clb.Checked[clb.Items.IndexOf('Startup')] then begin
Log('Startup.Create...');
hss:=GetHeapStatus;
with TMiTeC_Startup.Create(nil) do begin
onDebug:=MiTeC_Debug;
//ExceptionModes:=[emExceptionStack,emJournal];
Log('Startup.RefreshData...');
RefreshData;
if cbxReport.Checked then begin
Log('Startup.SaveToStorage...');
SaveToStorage(ss);
Log('Startup.LoadFromStorage...');
LoadFromStorage(ss);
end;
Log('Startup.Destroy...');
Free;
hsf:=GetHeapStatus;
if hsf.TotalAllocated>hss.TotalAllocated then begin
tl:=tl+hsf.TotalAllocated-hss.TotalAllocated;
Log(Format('*MEMORY LEAK = %d B',[hsf.TotalAllocated-hss.TotalAllocated]));
end;
Log('');
end;
end;
except on e: Exception do begin
Inc(ec);
Log(Format('*ERROR = %s'#13#10,[e.Message]));
end end;
try
if clb.Checked[clb.Items.IndexOf('ProcessList')] then begin
Log('ProcessList.Create...');
hss:=GetHeapStatus;
pl:=TMiTeC_ProcessList.Create(nil);
pl.onDebug:=MiTeC_Debug;
pl.DetectionRange:=[];
for i:=0 to clbPL.Items.Count-1 do
if clbPL.Checked[i] then
pl.DetectionRange:=pl.DetectionRange+[TDetectionType(i)];
with pl do begin
Log('ProcessList.RefreshData...');
if cbxSafe.Checked then begin
th:=BeginThread(nil,0,ProcessList_GetInfo_ThreadExecute,pl,0,n);
if (WaitForSingleObject(th,60000)=WAIT_TIMEOUT) then
TerminateThread(th,WAIT_TIMEOUT);
GetExitCodeThread(th,n);
if n<>0 then begin
if n=WAIT_TIMEOUT then
Box.Lines[Box.Lines.Count-1]:=Box.Lines[Box.Lines.Count-1]+'TIMEOUT EXPIRED...'
else
Box.Lines[Box.Lines.Count-1]:=Box.Lines[Box.Lines.Count-1]+Format('TERMINATED WITH ERROR %d...',[n]);
end;
end else
RefreshData;
if cbxReport.Checked then begin
Log('ProcessList.SaveToStorage...');
SaveToStorage(ss);
Log('ProcessList.LoadFromStorage...');
LoadFromStorage(ss);
end;
Log('ProcessList.Destroy...');
Free;
hsf:=GetHeapStatus;
if hsf.TotalAllocated>hss.TotalAllocated then begin
tl:=tl+hsf.TotalAllocated-hss.TotalAllocated;
Log(Format('*MEMORY LEAK = %d B',[hsf.TotalAllocated-hss.TotalAllocated]));
end;
Log('');
end;
end;
except on e: Exception do begin
Inc(ec);
Log(Format('*ERROR = %s'#13#10,[e.Message]));
end end;
try
if clb.Checked[clb.Items.IndexOf('USB')] then begin
Log('USB.Create...');
hss:=GetHeapStatus;
with TMiTeC_USB.Create(nil) do begin
onDebug:=MiTeC_Debug;
//ExceptionModes:=[emExceptionStack,emJournal];
Log('USB.RefreshData...');
RefreshData;
if cbxReport.Checked then begin
Log('USB.SaveToStorage...');
SaveToStorage(ss);
Log('USB.LoadFromStorage...');
LoadFromStorage(ss);
end;
Log('USB.Destroy...');
Free;
hsf:=GetHeapStatus;
if hsf.TotalAllocated>hss.TotalAllocated then begin
tl:=tl+hsf.TotalAllocated-hss.TotalAllocated;
Log(Format('*MEMORY LEAK = %d B',[hsf.TotalAllocated-hss.TotalAllocated]));
end;
Log('');
end;
end;
except on e: Exception do begin
Inc(ec);
Log(Format('*ERROR = %s'#13#10,[e.Message]));
end end;
try
if clb.Checked[clb.Items.IndexOf('Connections')] then begin
Log('Connections.Create...');
hss:=GetHeapStatus;
with TConnections.Create do begin
Log('Connections.RefreshData...');
Refresh;
Log('Connections.Destroy...');
Free;
hsf:=GetHeapStatus;
if hsf.TotalAllocated>hss.TotalAllocated then begin
tl:=tl+hsf.TotalAllocated-hss.TotalAllocated;
Log(Format('*MEMORY LEAK = %d B',[hsf.TotalAllocated-hss.TotalAllocated]));
end;
Log('');
end;
end;
except on e: Exception do begin
Inc(ec);
Log(Format('*ERROR = %s'#13#10,[e.Message]));
end end;
try
if cbxSI.Checked then begin
Log('SystemInfo.Create...');
hss:=GetHeapStatus;
with TMiTeC_SystemInfo.Create(Self) do begin
onDebug:=MiTeC_Debug;
//ExceptionModes:=[emExceptionStack,emJournal];
Log('SystemInfo.Refresh...');
RefreshData;
if cbxReport.Checked then begin
Log('SystemInfo.SaveToStorage...');
SaveToStorage(ss);
Log('SystemInfo.LoadFromStorage...');
LoadFromStorage(ss);
end;
if cbxExtra.Checked then begin
Log('SystemInfo.ShowModalOverview...');
ShowModalOverview;
end;
Log('SystemInfo.Destroy...');
Free;
hsf:=GetHeapStatus;
if hsf.TotalAllocated>hss.TotalAllocated then begin
tl:=tl+hsf.TotalAllocated-hss.TotalAllocated;
Log(Format('*MEMORY LEAK = %d B',[hsf.TotalAllocated-hss.TotalAllocated]));
end;
Log('');
end;
end;
except on e: Exception do begin
Inc(ec);
Log(Format('*ERROR = %s'#13#10,[e.Message]));
end end;
if tl>0 then begin
Log(Format('* TOTAL MEMORY LEAK = %d B',[tl]));
Log('');
end;
if ec>0 then begin
Log(Format('* TOTAL ERRORS = %d',[ec]));
Log('');
end;
bDM.Enabled:=debugs.Count>0;
Log('Test finished.');
finally
Screen.Cursor:=crDefault;
end;
end;
procedure Twnd_msicstest_Main.Log(AMessage: string);
var
_hs: THeapStatus;
begin
if (Box.Lines.Count>0) and (Box.Lines[Box.Lines.Count-1]<>'') and (Pos('*',Box.Lines[Box.Lines.Count-1])<>1) then begin
_hs:=GetHeapStatus;
Box.Lines[Box.Lines.Count-1]:=Box.Lines[Box.Lines.Count-1]+'OK '+Format('(%1.2f s / %d B)',[(GetTickCount-st)/1000,_hs.TotalAllocated-hs.TotalAllocated]);
end;
if Pos('...',AMessage)>0 then begin
st:=GetTickCount;
hs:=GetHeapStatus;
end;
Box.Lines.Add(AMessage);
Box.Lines.SaveToFile(ChangeFileExt(Application.ExeName,'.log'));
Update;
end;
procedure Twnd_msicstest_Main.MiTeC_Debug(Sender: TMiTeC_MSIC_Component;
Msg: string);
begin
debugs.Add(Format('%s: %s',[Sender.Classname,Msg]));
end;
procedure Twnd_msicstest_Main.FormCreate(Sender: TObject);
begin
debugs:=TStringList.Create;
clbPL.Checked[0]:=True;
end;
procedure Twnd_msicstest_Main.Button2Click(Sender: TObject);
begin
Box.Lines.Clear;
CheckAll;
end;
procedure Twnd_msicstest_Main.bDMClick(Sender: TObject);
begin
ShowDebug(debugs);
end;
procedure Twnd_msicstest_Main.Checkall1Click(Sender: TObject);
var
i: Integer;
begin
for i:=0 to clb.Items.Count-1 do
clb.Checked[i]:=TComponent(Sender).Tag=1;
end;
procedure Twnd_msicstest_Main.Inverse1Click(Sender: TObject);
var
i: Integer;
begin
for i:=0 to clb.Items.Count-1 do
clb.Checked[i]:=not clb.Checked[i];
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -