[comp.windows.ms.programmer] Enumerate Tasks

Gary_Capps@p27.f30.n147.z1.fidonet.org (Gary Capps) (04/28/91)

In a message of <24 Apr 91 17:18:00> Norbert Unterberg wrote to All:

 NU>Does anybody know if there is a way to get the task handles of all running
 NU>tasks? Maybe a function like EnumTasks (which doesn't exist). Windows
 NU>has functions like GetNumTasks() and GetCurrentTask(), but how can I get
 NU>task handles (or other task info) of all that tasks? There must be a way,
 NU>because HEAPWALK knows about the tasks! Well, the Task Manager does not,
 NU>it only displays the titles of all overlapped windows... 

Try using EnumWindows() and then calling GetWindowTask() for every window you 
find.

gc

Norbert_Unterberg@p4.f36.n245.z2.fidonet.org (Norbert Unterberg) (05/03/91)

 >  NU>Does anybody know if there is a way to get the task handles of all
 > running
 >  NU>tasks? Maybe a function like EnumTasks (which doesn't exist). Windows
 >
 > Try using EnumWindows() and then calling GetWindowTask() for every
 > window you find.

I've already had that idea, but that's not exactly what I'm looking for. What 
if there is a running task with no parent window? I've written a program 
similar to Launch or BackMenu which only subclasses the desktop window but does 
not create a window by itself. Those programs are not found when using 
EnumWindows(), but they are running tasks and therefore detected by 
GetNumTasks(). So how do I get those task handles? 
Norbert, 2:245/36.4

ejs@borland.com (Eric Swenson) (05/29/91)

In article <1276198232@p4.f36.n245.z2.fidonet.org> Norbert_Unterberg%p4.f36.n245.z2@hippo.dfv.rwth-aachen.de (Norbert Unterberg) writes:

>Does anybody know if there is a way to get the task handles of all running 
>tasks? Maybe a function like EnumTasks (which doesn't exist). Windows has 
>functions like GetNumTasks() and GetCurrentTask(), but how can I get task 
>handles (or other task info) of all that tasks? There must be a way, because 
>HEAPWALK knows about the tasks! Well, the Task Manager does not, it only 
>displays the titles of all overlapped windows...

In Windows 3.0, you have to use undocumented means to get the list of 
running tasks.  (You use GETTASKQUEUE and follow the chain of linked TDBs
until you get a null pointer).  For Windows 3.1, you can use the new TOOLHELP
DLL which gives you an entrypoint to enumerate all the tasks.  TOOLHELP is
available as part of the OpenTools program and the current version runs fine
under Windows 3.0.  This is the MS-recommended way to do what you want.  

-- Eric Swenson (ejs@borland.com)