Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Liste aller Threads einer Application (https://www.delphipraxis.net/44876-liste-aller-threads-einer-application.html)

DerAndereMicha 26. Apr 2005 10:15


Liste aller Threads einer Application
 
Wie bekomme ich eine Liste aller Threads heraus die in meiner Application gerade aktiv sind?

Vjay 26. Apr 2005 11:10

Re: Liste aller Threads einer Application
 
Hallo,

du solltest dies unter Zurhilfenahme der ToolHelp32 und den Funktionen Thread32First und Thread32Next hinbekommen.

NicoDE 26. Apr 2005 11:12

Re: Liste aller Threads einer Application
 
Delphi-Quellcode:
uses
  TlHelp32;

var
  Snapshot: THandle;
  Thread32: TThreadEntry32;
begin
  Snapshot := CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, GetCurrentProcessId());
  if (Snapshot <> 0) and (Snapshot <> INVALID_HANDLE_VALUE) then
    try
      ZeroMemory(&Thread32, SizeOf(TThreadEntry32));
      Thread32.dwSize := SizeOf(TThreadEntry32);
      if Thread32First(Snapshot, Thread32) then
        repeat
          //...
        until not Thread32Next(Snapshot, Thread32);
    finally
      CloseHandle(Snapshot);
    end;
end;

DerAndereMicha 26. Apr 2005 13:02

Re: Liste aller Threads einer Application
 
Danke, für die schnelle Hilfe :-)


Alle Zeitangaben in WEZ +1. Es ist jetzt 19:29 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz