Recent

Author Topic: Retrieving Hardware info on windows?  (Read 10463 times)

captian jaster

  • Guest
Retrieving Hardware info on windows?
« on: April 09, 2010, 01:40:30 am »
How would i obtain the hardware info(eg; Amount of Ram) in windows?

Silvio Clécio

  • Guest
Re: Retrieving Hardware info on windows?
« Reply #1 on: April 09, 2010, 02:58:32 am »
On Windows it is very easy. It is equal to Delphi:

Code: [Select]
uses
  Windows;

procedure TForm1.Timer1Timer(Sender: TObject);
const
  cBytesPorMb = 1024 * 1024;
var
  M: TMemoryStatus;
  T: string;
begin
  M.dwLength := SizeOf(M);
  GlobalMemoryStatus(M);
  Memo1.Clear;
  with Memo1.Lines do
  begin
    Add(Format('Memória em uso: %d%%', [M.dwMemoryLoad]));
    Add(Format('Total de física: %f MB', [M.dwTotalPhys / cBytesPorMB]));
    Add(Format('Total máx. paginação: %f MB', [M.dwTotalPageFile / cBytesPorMB]));
    Add(Format('Paginação disponível: %f MB', [M.dwAvailPageFile / cBytesPorMB]));
    Add(Format('Total vitual: %fMB', [M.dwTotalVirtual / cBytesPorMB]));
    Add(Format('Virtual disponível: %fMB', [M.dwAvailVirtual / cBytesPorMB]));
    T := formatfloat('#,##', (diskfree(0)));
    Add('Espaço Livre do HD: ' + copy(T, 1, 4) + ' MB');
    T := formatfloat('#,##', (DiskSize(0)));
    Add('Tamanho do HD: ' + copy(T, 1, 4) + ' MB');
  end;
end;

Source: http://www.planetadelphi.com.br/dica/3730/status-da-memoria

captian jaster

  • Guest
Re: Retrieving Hardware info on windows?
« Reply #2 on: April 09, 2010, 02:36:38 pm »
Dood its in spanish...

Silvio Clécio

  • Guest
Re: Retrieving Hardware info on windows?
« Reply #3 on: April 09, 2010, 02:41:27 pm »
In en:

Code: [Select]
(...)
    Add(Format('Memory in use: %d%%', [M.dwMemoryLoad]));
    Add(Format('Total physical: %f MB', [M.dwTotalPhys / cBytesPorMB]));
    Add(Format('Total max. pagination: %f MB', [M.dwTotalPageFile / cBytesPorMB]));
    Add(Format('Paging available: %f MB', [M.dwAvailPageFile / cBytesPorMB]));
    Add(Format('Total virtual: %fMB', [M.dwTotalVirtual / cBytesPorMB]));
    Add(Format('Virtual available: %fMB', [M.dwAvailVirtual / cBytesPorMB]));
    T := formatfloat('#,##', (diskfree(0)));
    Add('HD free space: ' + copy(T, 1, 4) + ' MB');
    T := formatfloat('#,##', (DiskSize(0)));
    Add('HD size: ' + copy(T, 1, 4) + ' MB');
(...)

minovitiello

  • New Member
  • *
  • Posts: 14
Re: Retrieving Hardware info on windows?
« Reply #4 on: January 27, 2011, 09:03:18 pm »
For unix (ubuntu) it's possible?
« Last Edit: January 27, 2011, 09:09:13 pm by minovitiello »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Retrieving Hardware info on windows?
« Reply #5 on: January 27, 2011, 11:47:44 pm »
Quote
For unix (ubuntu) it's possible?
Yep, but not with those Windows API functions. *nix stores hardware information in files. Examples for CPU and memory info:
http://linux.byexamples.com/archives/185/get-to-know-your-hardware-information/

captian jaster

  • Guest
Re: Retrieving Hardware info on windows?
« Reply #6 on: January 28, 2011, 10:48:06 pm »
For unix (ubuntu) it's possible?
ULTRA BUMP!
Quote
For unix (ubuntu) it's possible?
Yep, but not with those Windows API functions. *nix stores hardware information in files. Examples for CPU and memory info:
http://linux.byexamples.com/archives/185/get-to-know-your-hardware-information/
Thats a cool way of storing info :D

 

TinyPortal © 2005-2018