我要编程的方式获得。
又搞了一个,该有的路径没有,不该有的倒有了。
[Delphi] 纯文本查看 复制代码 program Project6;
{$APPTYPE CONSOLE}
uses
SysUtils,
Messages,
Windows,
Tlhelp32;
var
processRec: Thandle;
pe32: TProcessEntry32;
processNum: Integer;
procedure EnumModule(processid: DWORD);
var
moduleRec: THandle;
pm: TModuleEntry32;
begin
// create module snapshot
moduleRec := CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, processid);
//module size
pm.dwSize := sizeof(TModuleEntry32);
// first module?
if (module32First(moduleRec, pm)) then
begin
while Module32Next(moduleRec, pm) do
begin
Writeln('module name: ', StrPas(pm.szExePath));
end;
end;
CloseHandle(moduleRec);
end;
procedure OutProcessName(processName: string);
begin
WriteLn('Process Name:', processName);
end;
begin
processNum := 0;
//create process snapshot
processRec := CreateToolHelp32Snapshot(TH32CS_SNAPPROCESS, 0);
pe32.dwSize := sizeOf(TPROCESSENTRY32);
if Process32First(processRec, pe32) then
begin
// enum the process module
OutProcessName(pe32.szExeFile);
EnumModule(pe32.th32ProcessID);
inc(processNum); //inc process count
while Process32Next(processRec, pe32) do
begin
OutProcessName(pe32.szExeFile);
EnumModule(pe32.th32ProcessID);
inc(processNum); //inc process count
end;
WriteLn('Total System Process:', processNum);
CloseHandle(processRec);
Readln;
end;
end.
|