如何监控程序运行的列表,即知道当前计算机运行了那些程序,这些程序的文件名以及对应的磁盘文件。

解决方案 »

  1.   

    列出进程列表的程序就不给了,给你个取路径的:var
      ProcessSnapShotHandle: THandle;
      ProcessEntry: TProcessEntry32;
      ProcessHandle: THandle;
      Ret: BOOL;
      s: string;
      Position: Byte;  ModuleSnapShotHandle: THandle;
      ModuleEntry: TModuleEntry32;
    begin
      ProcessSnapShotHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
      if ProcessSnapShotHandle>0 then
      begin
        ProcessEntry.dwSize:=SizeOf(TProcessEntry32);
        Ret:=Process32First(ProcessSnapShotHandle, ProcessEntry);
        while Ret do
        begin
          ModuleSnapShotHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, ProcessEntry.th32ProcessID);
          if ModuleSnapShotHandle>0 then
          begin
             ModuleEntry.dwSize:=SizeOf(TModuleEntry32);
             Ret:=Module32First(ModuleSnapShotHandle, ModuleEntry);
             if Ret then
             begin
               s:=ModuleEntry.szExePath;
               CloseHandle(ModuleSnapShotHandle)
            end;
          Ret:=Process32Next(ProcessSnapShotHandle, ProcessEntry)
        end;
        CloseHandle(ProcessSnapShotHandle);
      end
    end;
    s里就是你要的了.
      

  2.   

    so many....就是创建进程快照 然后遍历
      

  3.   

    uses TLHelp32;
    {$R *.dfm}
    procedure SearchProcess(T:Tstrings);
    var lppe: TProcessEntry32;
        found : boolean;
        Hand : THandle;
    begin
      Hand := CreateToolhelp32Snapshot(TH32CS_SNAPALL,0);
      Found:=false;
      while not found do
      found := Process32First(Hand,lppe);
      T.Clear;
      while found do
      begin
        T.Add(copy(inttostr(lppe.th32ProcessID)+'               ',1,15)
             +StrPas(lppe.szExeFile));//列出所有进程。
        found := Process32Next(Hand,lppe);
      end;
    end;
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      SearchProcess(memo1.Lines)
    end