Board index » delphi » Delphi 1: Need to find the amount of ram on the computer running the application

Delphi 1: Need to find the amount of ram on the computer running the application

Hi Everyone

I'm stuck with a little problem. I need to find the amount of ram on the
computer that is running Delphi application. I know that there are diffrent
ways to do this in Delphi 3 and 4. But I'm stuck with Delphi 1.
The computer is running Windows 95/98 with 12 to 128 Meg of Ram.
And I need to find out exactly how much ram in the computer.

Is there someone out there that has solution for me.
I would appreciate it very much.

Ren Jean Aub
Programmer
au...@gov.nb.ca

 

Re:Delphi 1: Need to find the amount of ram on the computer running the application


Rene,
  Take a look at GetFreeSystemResources for memory usage, and
GetFreeSpace for total RAM.

-Dave

Quote
Rene Aube wrote:

> Hi Everyone

> I'm stuck with a little problem. I need to find the amount of ram on the
> computer that is running Delphi application. I know that there are diffrent
> ways to do this in Delphi 3 and 4. But I'm stuck with Delphi 1.
> The computer is running Windows 95/98 with 12 to 128 Meg of Ram.
> And I need to find out exactly how much ram in the computer.

> Is there someone out there that has solution for me.
> I would appreciate it very much.

> Ren Jean Aub
> Programmer
> au...@gov.nb.ca

--
David G. Parsons
Inprise Certified Delphi 4 Client/Server Developer
Tekmetrics Certified Delphi Programmer
Tekmetrics Certified Visual Basic 5 Programmer
URL: http://www.erols.com/dparsons
Email: dpars...@erols.com
FAX: (603) 947-8207

Re:Delphi 1: Need to find the amount of ram on the computer running the application


Quote
Rene Aube wrote:

> I'm stuck with a little problem. I need to find the amount of ram on the
> computer that is running Delphi application. I know that there are diffrent
> ways to do this in Delphi 3 and 4. But I'm stuck with Delphi 1.
> The computer is running Windows 95/98 with 12 to 128 Meg of Ram.
> And I need to find out exactly how much ram in the computer.

Try something like this.

function GetMemorySize: longint;
var
   memsiz: word;
begin
{ This calls interrupt 21 function 52 (get list of lists).
Offset 0x45 into the list is the ext mem installed, in Kbytes.
(DOS 4.X and above only) }
  asm
     push bx
     push es
     mov  ah,52h
     int 21h
     add bx,45h
     mov ax,es:[bx]
     mov memsiz,ax
     pop es
     pop bx
  end;
    result := longint(memsiz) * 1024 +640000;
end;

.....
.
var
  i:Integer;
begin
  i:=Trunc(GetMemorySize/1000000);
  if (i>=15) and (i<=17) then i:=16;        {It's a custom to say PC's RAM memory to}
  if (i>=30) and (i<=33) then i:=32;        {be exact full MBytes, like 4,8,16,32,64,128}
  if (i>=62) and (i<=65) then i:=64;        {and 256 MB. To get to these 'exact' numbers}
  if (i>=125) and (i<=129) then i:=128;     {this simplified test picks some rounding }
  if (i>=252) and (i<=258) then i:=256;     {errors away}
  Label1.Caption:='Amount of RAM memory is: 'IntToStr(i) +' MB';
  ...

Markku Nevalainen

Other Threads