05-01-2013، 07:44 AM
Gets the current application memory usage
نمونه کد :
نمونه کد :
کد:
unit Unit1;
interface
uses
Windows, Messages,psapi, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function CurrentMemoryUsage: Cardinal;
var
PMC: PsAPI.TProcessMemoryCounters; // receives info about process memory
begin
Result := 0; // default result on error or if not supported on OS
PMC.cb := SizeOf(PMC);
if PsAPI.GetProcessMemoryInfo(
Windows.GetCurrentProcess, @PMC, SizeOf(PMC)
) then
Result := PMC.WorkingSetSize;
end;
procedure TForm1.Button1Click(Sender: TObject);
//public by : parsicoders.com
begin
showmessage('CurrentMemoryUsage: ' +IntToStr(CurrentMemoryUsage));
end;
end.