如何得到一个进程所占的内存空间?(100分)

  • 主题发起人 主题发起人 artx
  • 开始时间 开始时间
A

artx

Unregistered / Unconfirmed
GUEST, unregistred user!
即求到一个进程从0x00400000 到 0x???????? 结束
 
uses tlhelp32;<br><br>function GetProcSize(ProcessID:DWORD):DWORD;<br>var b:BOOL;<br>&nbsp; &nbsp; SnapHandle:THandle;<br>&nbsp; &nbsp; Entry:TModuleEntry32;<br>begin<br>&nbsp; SnapHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPALL,ProcessID);<br>&nbsp; Entry.dwSize:=Sizeof(Entry);<br>&nbsp; b:=Module32First(SnapHandle,Entry);<br>&nbsp; while integer(b)&lt;&gt;0 do begin<br>&nbsp; &nbsp; if Entry.th32ModuleID=ProcessID then Result:=Entry.modBaseSize;<br>&nbsp; &nbsp; b:=Module32Next(SnapHandle,Entry);<br>&nbsp; end;<br>end;
 
啊啊啊啊,慢了!
 
是Entry.th32ModuleID=ProcessID 还是Entry.th32ProcessID=ProcessID?<br>我用Entry.th32ModuleID=ProcessID不对
 
sorry,我随手写的,有问题.<br><br>function GetProcModuleID(ProcessID:DWORD):DWORD;<br>var b:BOOL;<br>&nbsp; &nbsp; SnapHandle:THandle;<br>&nbsp; &nbsp; Entry:TProcessEntry32;<br>begin<br>&nbsp; SnapHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPALL,0);<br>&nbsp; Entry.dwSize:=Sizeof(Entry);<br>&nbsp; b:=Process32First(SnapHandle,Entry);<br>&nbsp; while integer(b)&lt;&gt;0 do begin<br>&nbsp; &nbsp; if Entry.th32ProcessID=ProcessID then Result:=Entry.th32ModuleID;<br>&nbsp; &nbsp; b:=Process32Next(SnapHandle,Entry);<br>&nbsp; end;<br>end;<br><br>function GetProcSize(ProcessID:DWORD):DWORD;<br>var b:BOOL;<br>&nbsp; &nbsp; SnapHandle:THandle;<br>&nbsp; &nbsp; Entry:TModuleEntry32;<br>&nbsp; &nbsp; ModuleID:DWORD;<br>begin<br>&nbsp; ModuleID:=GetProcModuleID(ProcessID);<br>&nbsp; SnapHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPALL,ProcessID);<br>&nbsp; Entry.dwSize:=Sizeof(Entry);<br>&nbsp; b:=Module32First(SnapHandle,Entry);<br>&nbsp; while integer(b)&lt;&gt;0 do begin<br>&nbsp; &nbsp; if Entry.th32ModuleID=ModuleID then Result:=Entry.modBaseSize;<br>&nbsp; &nbsp; b:=Module32Next(SnapHandle,Entry);<br>&nbsp; end;<br>end;
 
接受答案了.
 
后退
顶部