Solved

knowing computer resource?

Posted on 2001-09-17
6
180 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month4 days, 23 hours left to enroll

635 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