获得内存中所有的进程,那位能给解释一下代码啊(50分)

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

hugh8888

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure MemOk;<br>var<br> FSnapshotHandle:THandle;<br> FProcessEntry32:TProcessEntry32; &nbsp;//TProcessEntry32是什么类阿,找不到资料阿<br> Ret : BOOL;<br> ProcessHndle : THandle;<br> ProcessID : integer;<br> s:string;<br>begin<br> FSnapshotHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);<br> FProcessEntry32.dwSize:=Sizeof(FProcessEntry32); &nbsp; &nbsp;//这句卡助了,看不懂<br> Ret:=Process32First(FSnapshotHandle, FProcessEntry32);<br> ProcessID:=FProcessEntry32.th32ProcessID;<br> while Ret do<br> begin<br>  s:=ExtractFileName(FProcessEntry32.szExeFile);<br>  showmessage(s);<br>  Ret:=Process32Next(FSnapshotHandle, FProcessEntry32);<br> end;<br> CloseHandle(FSnapshotHandle);<br> ProcessHndle:=OpenProcess(PROCESS_VM_WRITE, false, ProcessID);<br> CloseHandle(ProcessHndle);<br>end;<br>蔡鸟阶段,跪求解释,
 
顶一下,再次跪求
 
TProcessEntry32是在TLHelp32.pas单元定义的一个记录结构:<br>{$EXTERNALSYM tagPROCESSENTRY32}<br>&nbsp; tagPROCESSENTRY32 = packed record<br>&nbsp; &nbsp; dwSize: DWORD;<br>&nbsp; &nbsp; cntUsage: DWORD;<br>&nbsp; &nbsp; th32ProcessID: DWORD; &nbsp; &nbsp; &nbsp; // this process<br>&nbsp; &nbsp; th32DefaultHeapID: DWORD;<br>&nbsp; &nbsp; th32ModuleID: DWORD; &nbsp; &nbsp; &nbsp; &nbsp;// associated exe<br>&nbsp; &nbsp; cntThreads: DWORD;<br>&nbsp; &nbsp; th32ParentProcessID: DWORD; // this process's parent process<br>&nbsp; &nbsp; pcPriClassBase: Longint; // Base priority of process's threads<br>&nbsp; &nbsp; dwFlags: DWORD;<br>&nbsp; &nbsp; szExeFile: array[0..MAX_PATH - 1] of Char;// Path<br>&nbsp; end;<br>&nbsp; TProcessEntry32 = tagPROCESSENTRY32;<br><br>FProcessEntry32.dwSize:=Sizeof(FProcessEntry32); &nbsp; &nbsp;//这句卡助了,看不懂<br>这句将FProcessEntry32记录的dwSize域设为TProcessEntry32记录的大小。<br>
 
接受答案了.
 
后退
顶部