9x下可用 TLHelp32 API<br>procedure GetProcessList(var AData: TStream);<br>var<br> TpzSnap: THandle;<br> lpPZ: TProcessEntry32;<br> Found: Boolean;<br> ModuleNameLen: Word;<br> FullPath: string;<br> ExeName: string;<br> FileInfo: TFileInformation;<br> FileSize: Integer;<br> FileDescription: string;<br> CompanyName: string;<br> ProductName, FileVersion: string;<br>begin<br> if not Assigned(AData) then Exit;<br> //创建进程快照<br> TpzSnap := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);<br> if TpzSnap <> 0 then begin<br> lpPz.dwSize := SizeOf(lpPz);<br> Found := TLHelp32.Process32First(TpzSnap, lpPZ);<br> while Found do begin<br> //格式: PID Integer|Parent PID Integer|线程数 Integer| FileSize| Len FileDescription|<br> //CompanyName| FileVersion|ProductName|映像名长度 Word| 映像名 Char //Full Path<br> AData.Write(lpPz.th32ProcessID, SizeoF(Integer));<br> AData.Write(lpPz.th32ParentProcessID, SizeoF(Integer));<br> AData.Write(lpPz.cntThreads, SizeoF(Integer));<br><br> FullPath := ImageFullName(lpPz.th32ProcessID);<br><br> FileInfo := TFileInformation.Create(FullPath);<br> try<br> try<br> FileSize := FileInfo.FileSize;<br> AData.Write(FileSize, SizeOf(FileSize));<br><br> FileDescription := FileInfo.FileDescription;<br> ModuleNameLen := Length(FileDescription);<br> AData.Write(ModuleNameLen, SizeOf(ModuleNameLen));<br> AData.Write(FileDescription[1], ModuleNameLen);<br><br> CompanyName := FileInfo.CompanyName;<br> ModuleNameLen := Length(CompanyName);<br> AData.Write(ModuleNameLen, SizeOf(ModuleNameLen));<br> AData.Write(CompanyName[1], ModuleNameLen);<br><br> FileVersion := FileInfo.FileVersion;<br> ModuleNameLen := Length(FileVersion);<br> AData.Write(ModuleNameLen, SizeOf(ModuleNameLen));<br> AData.Write(FileVersion[1], ModuleNameLen);<br><br> ProductName := FileInfo.ProductName;<br> ModuleNameLen := Length(ProductName);<br> AData.Write(ModuleNameLen, SizeOf(ModuleNameLen));<br> AData.Write(ProductName[1], ModuleNameLen);<br> except<br><br> end;<br> finally<br> FileInfo.Free;<br> end;<br><br><br> ExeName := ExtractFileName(lpPZ.szExeFile);<br> ModuleNameLen := Length(ExeName);<br> AData.Write(ModuleNameLen, SizeoF(ModuleNameLen));<br> AData.Write(ExeName[1], ModuleNameLen);<br> ExeName := '';<br><br> ModuleNameLen := Length(FullPath);<br> AData.Write(ModuleNameLen, SizeOf(ModuleNameLen));<br> AData.Write(FullPath[1], ModuleNameLen);<br><br> //查找下一进程式<br> Found := TLHelp32.Process32Next(TpzSnap, lpPz);<br> end;<br> CloseHandle(TpzSnap);<br> end; //if TpzSnap <> 0 then begin<br>end; //SendProcessList<br>2k 可用 TLHelp32, PSAPI API<br>EnumProcesses<br>EnumProcessModules