Solved

knowing computer resource?

Posted on 2001-09-17
6
173 Views
Last Modified: 2010-04-06
hello there ...,
Anyone know how to detect the current computer resource, or maybe memory usage?

thnx
0
Comment
Question by:el_shiro
6 Comments
 
LVL 22

Expert Comment

by:mnasman
ID: 6488457
Hello

  try to download free components to get system resouces include the memory form

http://www.torry.net/systeminfo.htm
0
 
LVL 22

Accepted Solution

by:
mnasman earned 50 total points
ID: 6488509
or you can use GlobalMemoryStatus API to retrive the total ram and the avalible

procedure TForm1.Button1Click(Sender: TObject);
var MemoryStatus: TMemoryStatus;
begin
 Memo1.Lines.Clear;
 MemoryStatus.dwLength := SizeOf(MemoryStatus);
 GlobalMemoryStatus(MemoryStatus);
 with MemoryStatus do begin
   Memo1.Lines.Add(IntToStr(dwLength) +
     ' Size of ''MemoryStatus'' record');
   Memo1.Lines.Add(IntToStr(dwMemoryLoad) +
     '% memory in use');
   Memo1.Lines.Add(IntToStr(dwTotalPhys) +
     ' Total Physical Memory in bytes');
   Memo1.Lines.Add(IntToStr(dwAvailPhys) +
     ' Available Physical Memory in bytes');
   Memo1.Lines.Add(IntToStr(dwTotalPageFile) +
     ' Total Bytes of Paging File');
   Memo1.Lines.Add(IntToStr(dwAvailPageFile) +
     ' Available bytes in paging file');
   Memo1.Lines.Add(IntToStr(dwTotalVirtual) +
     ' User Bytes of Address space');
   Memo1.Lines.Add(IntToStr(dwAvailVirtual) +
     ' Available User bytes of address space');
  end;
end;
0
 
LVL 44

Assisted Solution

by:CrazyOne
CrazyOne earned 50 total points
ID: 6489348
Well if you are looking to find what the System Resource percentage is then this should help you accomplish this. The following code is something Expert inthe came up with so if this works for you and if inthe wonders into this question please give inthe the points.

unit Thunker;

interface

const
 SYSres    = 0;
 USERres   = 2;
 GDIres    = 1;

function GetSystemResources(Res: Word): Word;
function UserPercentage : Integer;
function SystemPercentage : Integer;
function GDIPercentage : Integer;
procedure DisplayFreeResources;


implementation

uses Windows,SysUtils,Dialogs;

function ThunkLoadLibrary(LibraryName: PChar): THandle; stdcall; external kernel32 index 35;
procedure ThunkFreeLibrary(HInstance: THandle); stdcall; external kernel32 index 36;
function ThunkGetProcAddress(Hinstance: THandle; ProcName: PChar): Pointer; stdcall; external kernel32
index 37;
procedure Thunk; cdecl; external kernel32 name 'QT_Thunk';

{$StackFrames On}

var
 Th : THandle = 0;
 P: Pointer = nil;

function GetSystemResources(Res: Word): Word;
var
 Ar : array[0..$40] of Word;
begin
 Ar[0] := Th; //get major error without this ?
 Th := ThunkLoadLibrary('user.exe');
 if Th < 32 then
   raise Exception.Create('Error loading User.exe');
  ThunkFreeLibrary(Th);
 P := ThunkGetProcAddress(Th,'GetFreeSystemResources');
 if P = nil then
   raise Exception.Create('GetSystemResources function not found');
  asm
   push Res
   mov edx, P
   call Thunk
   mov Result, ax
 end;
end;

function UserPercentage : Integer;
begin
 Result := GetSystemResources(USERres);
end;

function SystemPercentage : Integer;
begin
 Result := GetSystemResources(SYSres);
end;

function GDIPercentage : Integer;
begin
 Result := GetSystemResources(GDIres);
end;

Procedure DisplayFreeResources;
begin
showmessage(
'SYSTEM : '+inttostr(SystemPercentage)+'%'+#13#10+
'USER : '+inttostr(UserPercentage)+'%'+#13#10+
'GDI : '+inttostr(GDIPercentage)+'%');
end;


The Crazy One
0
 
LVL 1

Expert Comment

by:mpoots
ID: 6490055
MNASMAN,

I liked your example.. Thanks!

Marcel (Holland)
0
 
LVL 17

Expert Comment

by:geobul
ID: 9308212
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

split points between mnasman and CrazyOne

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Thanks,

geobul
EE Cleanup Volunteer
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now