本文整理自网络,侵删。
//delphi 获得当前进程所使用的内存
uses PsAPI ...
//current memory size of the current process in bytes
function CurrentMemoryUsage: Cardinal;
var
pmc: TProcessMemoryCounters;
begin
pmc.cb := SizeOf(pmc) ;
if GetProcessMemoryInfo(GetCurrentProcess, @pmc, SizeOf(pmc)) then
Result := pmc.WorkingSetSize
else
RaiseLastOSError;
end;
To display the memory usage in KB, use:
ShowMessage(FormatFloat('Memory used: ,.# K', CurrentMemoryUsage / 1024)) ;
相关阅读 >>
Delphi issameday、istoday - 判断是不是同一天、判断是不是今天
更多相关阅读请进入《Delphi》频道 >>