UlteriusServer.Api.Win32.Desktop.GetInputProcesses C# (CSharp) Method

GetInputProcesses() public static method

Gets an array of all the processes running on the Input desktop.
public static GetInputProcesses ( ) : System.Diagnostics.Process[]
return System.Diagnostics.Process[]
        public static Process[] GetInputProcesses()
        {
            // get all processes.
            var processes = Process.GetProcesses();

            var m_procs = new ArrayList();

            // get the current desktop name.
            var currentDesktop = GetDesktopName(Input.DesktopHandle);

            // cycle through the processes.
            foreach (var process in processes)
            {
                // check the threads of the process - are they in this one?
                if (process.Threads.Cast<ProcessThread>().Any(pt => GetDesktopName(GetThreadDesktop(pt.Id)) == currentDesktop))
                {
                    m_procs.Add(process);
                }
            }

            // put ArrayList into array.
            var procs = new Process[m_procs.Count];

            for (var i = 0; i < procs.Length; i++) procs[i] = (Process)m_procs[i];

            return procs;
        }