unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, StdCtrls, ExtCtrls, ShellApi, Menus;
const
WM_TRAYEVENT = WM_USER + 1337;
type
TForm1 =
class(TForm)
ProgressBar1: TProgressBar;
Button2: TButton;
Timer1: TTimer;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
PopupMenu1: TPopupMenu;
Clos1: TMenuItem;
Label4: TLabel;
Label5: TLabel;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Clos1Click(Sender: TObject);
private
{ Private-Deklarationen }
procedure TrayEvent(
var msg : TMessage);
message WM_TRAYEVENT;
public
end;
var
Form1: TForm1;
ti: tnotifyicondata;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
var
x, y : real;
memory: TMemoryStatus;
Auslastung: integer;
begin
memory.dwLength := SizeOf(memory);
GlobalMemoryStatus(memory);
x := memory.dwTotalPhys - memory.dwAvailPhys;
y := memory.dwTotalPhys;
Auslastung := round(((x/y)*100));
ProgressBar1.Position := Auslastung;
Label3.Caption := IntToStr(Auslastung);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
with ti
do
begin
cbSize := SizeOf(ti);
Wnd :=
Handle;
uID := 100;
uFlags := NIF_MESSAGE + NIF_ICON + NIF_TIP;
uCallBackMessage := WM_TRAYEVENT;
hIcon := Application.Icon.Handle;
szTip := '
RAM Auslastung';
end;
Shell_NotifyIcon(NIM_ADD,@ti);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE,@ti);
end;
procedure TForm1.TrayEvent(
var msg: TMessage);
var
pt : TPoint;
begin
case msg.lparamlo
of
WM_RBUTTONDOWN :
begin
GetCursorPos(pt);
SetForeGroundWindow(
handle);
PopupMenu1.popup(pt.x,pt.y);
end;
end;
end;
procedure TForm1.Clos1Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Label5.Caption := IntToStr(SizeOf(memory));
end;
end.