unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ExtCtrls, StdCtrls;
type
[...]
var
Form1: TForm1;
alt, Auslastung, difpro: integer;
fertig: bool;
sdtime: real;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
var
x, y: real;
memory: TMemoryStatus;
begin
alt:=auslastung;
memory.dwLength := SizeOf(memory);
GlobalMemoryStatus(memory);
x := memory.dwTotalPhys - memory.dwAvailPhys;
y := memory.dwTotalPhys;
Auslastung := round(((x/y)*100));
ProgressBar1.Position := Auslastung;
edtot.text:=floattostr(round(y/1000000)) + ' MB';
edavail.text:=floattostr(round(memory.dwAvailPhys/1000000)) + ' MB';
edused.Text:=floattostr(round(x/1000000)) + ' MB';
lbp.Caption:=inttostr(Auslastung) + ' %';
if alt-auslastung > difpro then
begin
fertig:=true;
edsd.enabled:=false;
labelstat.Caption:='Fertig!';
end;
if fertig then
begin
if cbbeep.checked then beep;
sdtime:=sdtime-1;
progressbar2.Position:=round(2*strtofloat(edsd.text)-sdtime);
lbretime.caption:=floattostr(sdtime/2) + ' sek';
end;
if sdtime = 0 then
begin
fertig:=false;
edsd.enabled:=true;
labelstat.caption:='';
progressbar2.Position:=0;
sdtime:=2*strtoint(edsd.text);
lbretime.caption:=edsd.text + ' sek';
if cbshutdown.checked then
showmessage('Shutdown')
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE + SWP_NOMOVE + SWP_NOSIZE);
fertig:=false;
sdtime:=20;
difpro:=10;
end;
procedure TForm1.btstopClick(Sender: TObject);
begin
fertig:=false;
edsd.enabled:=true;
labelstat.caption:='';
progressbar2.Position:=0;
sdtime:=2*strtoint(edsd.text);
lbretime.caption:=edsd.text + ' sek';
end;
procedure TForm1.edsdExit(Sender: TObject);
begin
sdtime:=2*strtoint(edsd.text);
progressbar2.Max:=round(2*strtofloat(edsd.text));
end;
procedure TForm1.edproExit(Sender: TObject);
begin
difpro:=strtoint(edpro.text);
end;
end.