1
0
mirror of https://bitbucket.org/Dennis07/lina-components.git synced 2025-02-12 10:25:59 +02:00

Version 1.0 DEV 1.09

Signed-off-by: Dennis07 <den.goehlert@t-online.de>
This commit is contained in:
Dennis07 2014-09-21 20:16:51 +02:00
parent 5850bf94cd
commit 403a5a1525
20 changed files with 264 additions and 4 deletions

View File

@ -1,4 +1,4 @@
These statistics cover the official repository of Lina Components.
Total lines of code (LoC): 4500+
Total visual components (VC): 11
Total lines of code (LoC): 4700+
Total visual components (VC): 13

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

View File

@ -19,6 +19,9 @@ TLOCALIZATIONMANAGER32 BITMAP "Bitmap\Large\TLocalizationManager.bmp"
TPAINTMEMO BITMAP "Bitmap\TPaintMemo.bmp"
TPAINTMEMO16 BITMAP "Bitmap\Small\TPaintMemo.bmp"
TPAINTMEMO32 BITMAP "Bitmap\Large\TPaintMemo.bmp"
TPROCESSMANAGER BITMAP "Bitmap\TProcessManager.bmp"
TPROCESSMANAGER16 BITMAP "Bitmap\Small\TProcessManager.bmp"
TPROCESSMANAGER32 BITMAP "Bitmap\Large\TProcessManager.bmp"
TSCRIPTMANAGER BITMAP "Bitmap\TScriptManager.bmp"
TSCRIPTMANAGER16 BITMAP "Bitmap\Small\TScriptManager.bmp"
TSCRIPTMANAGER32 BITMAP "Bitmap\Large\TScriptManager.bmp"

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -10,10 +10,14 @@ interface
uses
{ Standard-Units }
SysUtils, Classes, Windows,
SysUtils, Classes, Windows, TlHelp32, PsAPI,
{ Andere Package-Units }
uBase, uSysTools;
type
{ Fehlermeldungen }
EBatteryFlag = class(Exception);
type
{ Hilfsklassen }
TBatteryFlag = (bfHealthy,bfLow,bfCritical,bfCharge,bfHealthyAccu,bfNone,bfUnknown);
@ -56,6 +60,31 @@ type
property About: TComponentAbout read FAbout;
end;
TProcessManager = class(TComponent)
private
{ Private-Deklarationen }
FAbout: TComponentAbout;
FNames: TStrings;
FTimeOut: DWORD;
public
{ Public-Deklarationen }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Update;
procedure Kill(ProcID: DWORD);
function GetID(ProcName: String): DWORD;
function GetPath(ProcID: DWORD): String;
function GetThreads(ProcName: String): DWORD;
function GetParentID(ProcName: String): DWORD;
function GetPriority(ProcName: String): Integer;
function GetMemory(ProcID: DWORD): DWORD;
published
{ Published-Deklarationen }
property About: TComponentAbout read FAbout;
property Names: TStrings read FNames;
property TimeOut: DWORD read FTimeOut write FTimeOut;
end;
procedure Register;
const
@ -78,11 +107,16 @@ const
CursorFixComponent_Copyright = 'Copyright © 2014';
CursorFixComponent_Author = 'Dennis Göhlert a.o.';
ProcessManagerComponent_Name = 'ProcessManager';
ProcessManagerComponent_Version = 1.0;
ProcessManagerComponent_Copyright = 'Copyright © 2014';
ProcessManagerComponent_Author = 'Dennis Göhlert a.o.';
implementation
procedure Register;
begin
RegisterComponents(ComponentsPage,[TBattery,TCursorFix]);
RegisterComponents(ComponentsPage,[TBattery,TCursorFix,TProcessManager]);
end;
{ ----------------------------------------------------------------------------
@ -99,6 +133,10 @@ begin
9: Result := bfHealthyAccu;
128: Result := bfNone;
255: Result := bfUnknown;
else
begin
raise EBatteryFlag.Create('Unable to obtain battery flag information');
end;
end;
end;
@ -211,4 +249,223 @@ begin
inherited;
end;
{ ----------------------------------------------------------------------------
TProcessManager
---------------------------------------------------------------------------- }
constructor TProcessManager.Create(AOwner: TComponent);
begin
inherited;
FAbout := TComponentAbout.Create(ProcessManagerComponent_Name,ProcessManagerComponent_Version,ProcessManagerComponent_Copyright,ProcessManagerComponent_Author);
FNames := TStringList.Create;
end;
destructor TProcessManager.Destroy;
begin
FAbout.Free;
FNames.Free;
inherited;
end;
procedure TProcessManager.Update;
var
Snapshot: THandle;
ProcEntry: TProcessEntry32;
begin
FNames.Clear;
Snapshot := CreateToolHelp32Snapshot(TH32CS_SNAPPROCESS,0);
try
ProcEntry.dwSize := SizeOf(ProcEntry);
if Process32First(Snapshot,ProcEntry) then
begin
repeat
FNames.Add(ProcEntry.szExeFile);
until (Process32Next(Snapshot,ProcEntry) = False)
end else
begin
RaiseLastOSError;
end;
finally
CloseHandle(Snapshot);
end;
end;
procedure TProcessManager.Kill(ProcID: DWORD);
var
CurrentProc: THandle;
Error: DWORD;
begin
CurrentProc := OpenProcess(SYNCHRONIZE or PROCESS_TERMINATE,False,ProcID);
try
if CurrentProc > 0 then
begin
Error := Integer(TerminateProcess(CurrentProc,1));
if Error <> 0 then
begin
Error := WaitForSingleObject(CurrentProc,FTimeOut);
if Error = WAIT_FAILED then
begin
RaiseLastOSError;
end;
end else
begin
RaiseLastOSError;
end;
end else
begin
RaiseLastOSError;
end;
finally
CloseHandle(CurrentProc);
end;
end;
function TProcessManager.GetID(ProcName: String): DWORD;
var
Snapshot: THandle;
ProcEntry: TProcessEntry32;
begin
Result := 0;
Snapshot := CreateToolHelp32Snapshot(TH32CS_SNAPPROCESS,0);
try
ProcEntry.dwSize := SizeOf(ProcEntry);
if Process32First(Snapshot,ProcEntry) then
begin
repeat
if Pos(AnsiLowerCase(ProcEntry.szExeFile),AnsiLowerCase(ExtractFilename(ProcName))) > 0 then
begin
Result := ProcEntry.th32ProcessID;
Break;
end;
until (Process32Next(Snapshot,ProcEntry) = False)
end else
begin
RaiseLastOSError;
end;
finally
CloseHandle(Snapshot);
end;
end;
function TProcessManager.GetPath(ProcID: DWORD): String;
var
Snapshot: THandle;
ModEntry: TModuleEntry32;
begin
Result := '';
Snapshot := CreateToolHelp32Snapshot(TH32CS_SNAPMODULE,ProcID);
try
ModEntry.dwSize := SizeOf(ModEntry);
if Module32First(Snapshot,ModEntry) then
begin
Result := ModEntry.szExePath;
end else
begin
RaiseLastOSError;
end;
finally
CloseHandle(Snapshot);
end;
end;
function TProcessManager.GetThreads(ProcName: String): DWORD;
var
Snapshot: THandle;
ProcEntry: TProcessEntry32;
begin
Result := 0;
Snapshot := CreateToolHelp32Snapshot(TH32CS_SNAPPROCESS,0);
try
ProcEntry.dwSize := SizeOf(ProcEntry);
if Process32First(Snapshot,ProcEntry) then
begin
repeat
if Pos(AnsiLowerCase(ProcEntry.szExeFile),AnsiLowerCase(ExtractFilename(ProcName))) > 0 then
begin
Result := ProcEntry.cntThreads;
Break;
end;
until (Process32Next(Snapshot,ProcEntry) = False)
end else
begin
RaiseLastOSError;
end;
finally
CloseHandle(Snapshot);
end;
end;
function TProcessManager.GetParentID(ProcName: String): DWORD;
var
Snapshot: THandle;
ProcEntry: TProcessEntry32;
begin
Result := 0;
Snapshot := CreateToolHelp32Snapshot(TH32CS_SNAPPROCESS,0);
try
ProcEntry.dwSize := SizeOf(ProcEntry);
if Process32First(Snapshot,ProcEntry) then
begin
repeat
if Pos(AnsiLowerCase(ProcEntry.szExeFile),AnsiLowerCase(ExtractFilename(ProcName))) > 0 then
begin
Result := ProcEntry.th32ParentProcessID;
Break;
end;
until (Process32Next(Snapshot,ProcEntry) = False)
end else
begin
RaiseLastOSError;
end;
finally
CloseHandle(Snapshot);
end;
end;
function TProcessManager.GetPriority(ProcName: String): Integer;
var
Snapshot: THandle;
ProcEntry: TProcessEntry32;
begin
Result := -1;
Snapshot := CreateToolHelp32Snapshot(TH32CS_SNAPPROCESS,0);
try
ProcEntry.dwSize := SizeOf(ProcEntry);
if Process32First(Snapshot,ProcEntry) then
begin
repeat
if Pos(AnsiLowerCase(ProcEntry.szExeFile),AnsiLowerCase(ExtractFilename(ProcName))) > 0 then
begin
Result := ProcEntry.pcPriClassBase;
Break;
end;
until (Process32Next(Snapshot,ProcEntry) = False)
end else
begin
RaiseLastOSError;
end;
finally
CloseHandle(Snapshot);
end;
end;
function TProcessManager.GetMemory(ProcID: DWORD): DWORD;
var
ProcMem: PPROCESS_MEMORY_COUNTERS;
CB: Integer;
begin
Result := 0;
CB := SizeOf(_PROCESS_MEMORY_COUNTERS);
GetMem(ProcMem,CB);
ProcMem^.cb := CB;
try
if GetProcessMemoryInfo(OpenProcess(PROCESS_ALL_ACCESS,False,ProcID),ProcMem,CB) = True then
begin
Result := ProcMem^.WorkingSetSize;
end;
finally
FreeMem(ProcMem);
end;
end;
end.