Forum > General
Retrieving Hardware info on windows?
captian jaster:
How would i obtain the hardware info(eg; Amount of Ram) in windows?
Silvio Clécio:
On Windows it is very easy. It is equal to Delphi:
--- Code: ---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;
--- End code ---
Source: http://www.planetadelphi.com.br/dica/3730/status-da-memoria
captian jaster:
Dood its in spanish...
Silvio Clécio:
In en:
--- Code: ---(...)
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');
(...)
--- End code ---
minovitiello:
For unix (ubuntu) it's possible?
Navigation
[0] Message Index
[#] Next page