How to Gets Thread Count in a Process

  03/21/2010, Yazar: Özgür Koca, Kategori: Delphi

Herhangi bir prosesin (işlem) bünyesinde bulunan thread (kanal) sayısını almak için aşağıdaki alt programı kullanabilirsiniz. GetCurrentProcessId çalışmakta olan programın prosess kimlik numarasını getirir. TlHelp32 ünitesini dahil etmeyi unutmayın.

implementation
uses TlHelp32;

function ThreadCount(iProcessID: DWord): integer;
var
  SnapHandle: THandle;
  ProcEntry: TProcessEntry32;
begin
  Result := 0;
  SnapHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  if SnapHandle = 0 then Exit;
  FillChar(ProcEntry, SizeOf(TProcessEntry32), 0);
  ProcEntry.dwSize := SizeOf(TProcessEntry32);
  if Process32First(SnapHandle, ProcEntry) then
  begin
    if ProcEntry.th32ProcessID = iProcessID then
    begin
      Result := ProcEntry.cntThreads;
      Exit;
    end;
    while Process32Next(SnapHandle, ProcEntry) = true do
    begin
      if ProcEntry.th32ProcessID = iProcessID then
      begin
        Result := ProcEntry.cntThreads;
        Break;
      end;
    end;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Caption := inttostr( ThreadCount( GetCurrentProcessId ));
end;

delphi snaphandle : thandle; (1), getthreadcount delphi (1), snaphandle := createtoolhelp32snapshot(th32cs_snapprocess 0); (1), thread count in a process (1)







Bu yazıya puan verin: 1 Puan2 Puan3 Puan4 Puan5 Puan6 Puan7 Puan8 Puan9 Puan10 Puan


Biraz gürültü yapın





Not: Yazdığınız yorum yönetici tarafından onaylandıktan sonra yayınlanacaktır.


  Yorumlara eposta ile abone ol




  • Hakkında | İletişim | Wordpress.org | RSS | Abone Ol

  • (c) 2005-2009 Wordpress Tema: Tankado & Theme by Tankado.com