dephi进程统计原程序 请高手给我看看这个程序怎么写啊  谢谢啊!

解决方案 »

  1.   

    //这是个枚举进程表的代码procedure TForm1.Button1Click(Sender: TObject);
    var
      FProcessEntry32: TProcessEntry32;
      PID: integer;
      List: TStringList;
      ModuleListHandle: Thandle;
      ModuleStruct: TMODULEENTRY32;
      J: integer;
      Yn: boolean;
    begin
      if Combobox1.itemindex = -1 then exit;
      List := TStringList.Create;
      FProcessEntry32 := GetProcessID(List, Combobox1.text);
      PID := FProcessEntry32.th32ProcessID;
      ModuleListHandle := CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, pID);
      ListBox1.Items.Clear;
      ModuleStruct.dwSize := sizeof(ModuleStruct);
      yn := Module32First(ModuleListHandle, ModuleStruct);
      j := 0;
      while (yn) do
      begin
        SetLength(ModuleArray, j + 1);
        ModuleArray[j] := ModuleStruct;
        ListBox1.Items.Add(ModuleStruct.szExePath);
        yn := Module32Next(ModuleListHandle, ModuleStruct);
        J := j + 1;
      end;
      CloseHandle(ModuleListHandle);
    end;