Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How do I get the system resources and memory available?

Posted on 2000-02-27
3
Medium Priority
?
177 Views
Last Modified: 2010-04-04
How do I get the system resources and memory available?
I want to get this information for using in my aboutbox.

                           Thank you
                           Lekhaew
0
Comment
Question by:lekhaew
3 Comments
 
LVL 3

Expert Comment

by:Alisher_N
ID: 2563030
maybe this one?

var
  Mstat1 : TMemoryStatus;
{
  PMemoryStatus = ^TMemoryStatus;
  _MEMORYSTATUS = record
    dwLength: DWORD;
    dwMemoryLoad: DWORD;
    dwTotalPhys: DWORD;
    dwAvailPhys: DWORD;
    dwTotalPageFile: DWORD;
    dwAvailPageFile: DWORD;
    dwTotalVirtual: DWORD;
    dwAvailVirtual: DWORD;
  end;
}
begin
  FillChar( Mstat1, SizeOf( _MemoryStatus ), 0 );
  Mstat1.dwLength := SizeOf( _MemoryStatus );
  GlobalMemoryStatus( Mstat1 );
  showmessage( 'Phys. available: ' + IntToStr(Mstat1.dwAvailPhys));
end.
0
 
LVL 17

Accepted Solution

by:
inthe earned 200 total points
ID: 2563149
hi
the following shows you the system/user and gdi resources
Regards Barry


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;

end.



example program would include:

uses Thunker;

procedure TForm1.Button1Click(Sender: TObject);
begin
DisplayFreeResources;
end;
0
 

Author Comment

by:lekhaew
ID: 2571970
Thanks.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

824 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