Solved

knowing computer resource?

Posted on 2001-09-17
6
178 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

713 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