如何使用delphi查出一个进程使用的内存量啊(50分)

  • 主题发起人 主题发起人 zhulu2008
  • 开始时间 开始时间
Z

zhulu2008

Unregistered / Unconfirmed
GUEST, unregistred user!
急死了,大家帮帮忙哈
 
procedure TForm1.Button2Click(Sender: TObject);<br>var<br>&nbsp; bAddr: DWORD;<br>&nbsp; SysInfo: SYSTEM_INFO;<br>&nbsp; MemInfo: TMemoryBasicInformation;<br>&nbsp; hProc: THandle;<br>&nbsp; mt: DWORD;<br>begin<br>&nbsp; mt := 0;<br>&nbsp; hProc := OpenProcess(PROCESS_ALL_ACCESS,False,GetCurrentProcessId);<br>&nbsp; GetSystemInfo(SysInfo);<br>&nbsp; bAddr := DWORD(SysInfo.lpMinimumApplicationAddress);<br><br>&nbsp; while VirtualQueryEx(hProc,Pointer(bAddr),MemInfo,SizeOf(MemInfo)) &lt;&gt; 0 do<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; if (MemInfo.State = MEM_COMMIT) then<br>&nbsp; &nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mt := mt + MemInfo.RegionSize;<br>&nbsp; &nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; &nbsp; bAddr := MemInfo.RegionSize + DWORD(MemInfo.BaseAddress);<br>&nbsp; &nbsp; end;<br>&nbsp; ShowMessage(IntToStr(mt div 1024));<br>end;
 
后退
顶部