How to Gets Thread Count in a Process
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)
Delphi kategorilerinde yayınlanan yazılara abone olarak haberdar olun.
Abone olmak için aşağıdaki kutuya adresinizi yazınız.
Turkish
English
Chinese
