Solved

knowing computer resource?

Posted on 2001-09-17
6
174 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:Mohammed Nasman
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:
Mohammed Nasman 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

867 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

22 Experts available now in Live!

Get 1:1 Help Now