Beim Erstellen mitzählen? Oder so:
Delphi-Quellcode:
uses tlhelp32;
function GetThreadCount(ProcID: Cardinal): integer;
var
pe32: TProcessEntry32;
SnapShot: THandle;
NumThreads: Cardinal;
begin
NumThreads := 0;
SnapShot := CreateToolHelp32SnapShot(TH32CS_SNAPPROCESS, ProcID);
if SnapShot <> INVALID_HANDLE_VALUE then
try
pe32.dwSize := SizeOf(ProcessEntry32);
if Process32First(SnapShot, pe32) then
NumThreads := pe32.cntThreads;
finally
CloseHandle(SnapShot);
end;
result := NumThreads;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(IntToStr(GetThreadCount(0))); // 0: current process
end;