Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

knowing computer resource?

Posted on 2001-09-17
6
Medium Priority
?
184 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 200 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 200 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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

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 I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

722 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