delphiwinapi

How enumerate threads running in a specific desktop?


Suppose that a process calls the SetThreadDesktop() API to capture the screen of a specific desktop.

Is it possible to identify this thread inside of the desktop and know the caller process?

If yes, could you provide a code example for it?


Solution

  • There is not a specific API to enumerate threads in a desktop. You will have to enumerate all available threads using CreateToolhelp32Snapshot() and Thread32(First|Next)() (see Enumerating threads in Windows), and then filter them using GetThreadDesktop().