Esempio n. 1
0
        public static IEnumerable <IntPtr> EnumerateProcessWindowHandles(int processId)
        {
            var handles = new List <IntPtr>();

            foreach (ProcessThread thread in Process.GetProcessById(processId).Threads)
            {
                User32Interop.EnumThreadWindows(thread.Id, (hWnd, lParam) => {
                    handles.Add(hWnd);
                    return(true);
                }, IntPtr.Zero);
            }

            return(handles);
        }