16.10.2012, 09:15
|
Прохожий
|
|
Регистрация: 06.10.2012
Сообщения: 8
Репутация: 10
|
|
клиент
Код:
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ScktComp,Processor, ComCtrls,GraphBuilder,Tlhelp32,
ExtCtrls, WinSock;
type
TForm2 = class(TForm)
ClientSocket1: TClientSocket;
Edit1: TEdit;
Button1: TButton;
Timer1: TTimer;
Edit2: TEdit;
Memo1: TMemo;
Label1: TLabel;
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
CPU : Integer;
Processor: TProcessor;
memtot, memavail,memuse: integer;
s:string;
Co:BOOL;
implementation
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
clientsocket1.Active:=false;
clientsocket1.Active:=true;
end;
procedure TForm2.FormCreate(Sender: TObject);
var
MemoryStatus: TMemoryStatus;
begin
ClientSocket1.Open;
Processor:=TProcessor.Create(Application);
Processor.Init;
MemoryStatus.dwLength := SizeOf(MemoryStatus) ;
GlobalMemoryStatus(MemoryStatus) ;
with MemoryStatus do
begin
memtot:= (dwTotalPhys div 1048576);
memavail:=(dwAvailPhys div 1048576);
memuse:= (dwMemoryLoad);
end;
end;
procedure TForm2.FormDestroy(Sender: TObject);
begin ;
ClientSocket1.Close;
FreeAndNil(Processor);
end;
{ function TimeWorks: String;
var
Hours,
Minutes,
TheLength: Integer;
begin
TheLength:=GetTickCount;
Hours:=TheLength div 3600000;
Minutes:=(TheLength mod 3600000) div 60000;
// ShowWindow (Application.handle, SW_HIDE);
result := IntToStr(Hours)+' часов '+IntToStr(Minutes)+' минут ';
end; }
procedure TForm2.Timer1Timer(Sender: TObject);
var
MemoryStatus: TMemoryStatus;
ProcUsege:integer;
begin
ProcUsege:=Processor.CPUUsageNow;
// time:= TimeWorks;
s:=inttostr(ProcUsege);//+'/'+ (inttostr(memtot))+'/'+ inttostr(memavail)+'/' +inttostr(memuse);
//edit1.Text:=inttostr(memtot);
ClientSocket1.Socket.SendText(s);
MemoryStatus.dwLength := SizeOf(MemoryStatus) ;
GlobalMemoryStatus(MemoryStatus) ;
with MemoryStatus do
begin
memtot:= (dwTotalPhys div 1048576);
memavail:=(dwAvailPhys div 1048576);
memuse:= (dwMemoryLoad);
end;
end;
end.
|