如何知道自己程序所占的内存。(UP有分 )(100分)

  • 主题发起人 主题发起人 hikehilter
  • 开始时间 开始时间
H

hikehilter

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TFrmMain.TimerTimer(Sender: TObject);
var
FHandle:Integer;
FSnapshotHandle: THandle;
FProcessEntry32: TProcessEntry32;
hProcess:hwnd;
ContinueLoop:Boolean;

SysInfo:SYSTEM_INFO ;
SysTemInfo:MEMORY_BASIC_INFORMATION;
MemoryTotal:Cardinal;
TmpbaseAdd:Pointer;
LpMem:^Integer;
begin
//Check if have Ie programming

//check if othere windows handle ,if have ,will close this windows handle
FSnapshotHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
FProcessEntry32.dwSize := Sizeof(FProcessEntry32);
ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);

while integer(ContinueLoop) <> 0 do
begin
hProcess:=OpenProcess(PROCESS_ALL_ACCESS,TRUE,FProcessEntry32.th32ProcessID);
GetSystemInfo(SysInfo);
lpMem := SysInfo.lpMinimumApplicationAddress;
While (VirtualQueryEx(hProcess,lpMem,SysTemInfo,SizeOf(SysTemInfo)) =SizeOf(SysTemInfo))do
begin
if SysTemInfo.State =MEM_COMMIT then
MemoryTotal:=MemoryTotal+SysTemInfo.RegionSize;
end;
ContinueLoop := Process32Next(FSnapshotHandle,
FProcessEntry32);
end;
CloseHandle(FSnapshotHandle);
close;

中间的怎么写。求招。
 
不知道,帮你提前
 
后退
顶部